using System.ComponentModel;
using Tutorial2.Domain;
using Tutorial2.Service;
namespace Tutorial2.Application
{
public class BlogPresenter
{
private readonly IBlogService _service = null;
private readonly IBlogView _view = null;
///
/// Initializes a new instance of the class.
///
/// The view.
/// The service.
///
/// Use "Dependency Injection" to attach the dependencies for the view and service.
///
public BlogPresenter(IBlogView view, IBlogService service)
{
_view = view;
_service = service;
}
///
/// Check for User.
///
/// The login.
/// The password.
public void Verify(string login, string password)
{
_view.Author = _service.Verify(login, password);
}
///
/// Creates the blog.
///
/// The name.
/// The description.
public void CreateBlog(string name, string description)
{
Blog blog = new Blog();
blog.Name = name;
blog.Description = description;
_service.SaveBlog(blog);
_view.Blog = blog;
}
///
/// Creates the post.
///
/// The title.
/// The text.
public void CreatePost(string title, string text)
{
Post post = new Post();
post.Title = title;
post.Content = text;
post.Blog = _view.Blog;
_service.SavePost(post);
_view.Blog.Posts.Add(post);
}
}
}