public void EditBlog() { _container = EntityContainer.EditableContainer <Domain.Models.Blog> .ContainerConfig(_blog.ID); try { using (var scope = _container.BeginLifetimeScope()) { var editableBlog = scope.Resolve <EntityService.Interfaces.IEditable <Domain.Models.Blog> >(); var Blog = new Domain.Models.Blog() { Title = "edit test", ShortText = "edit test short text", ImageFileAddress = "edit test", TextFileAddress = "edit test file ", TimeToRead = 15, Writer = "edit test writer" }; editableBlog.Edit(Blog); } } catch (Exception error) { Assert.Fail(error.Message); } }
public void ValidInsert() { try { Domain.Models.Blog blog = new Domain.Models.Blog() { ImageFileAddress = "test", ShortText = "short text test", TextFileAddress = "text address", TimeToRead = 10, Title = "test title", Writer = "test writer", Category = new Domain.Models.Category() { ID = "01a" } }; insertableIntractor.Insert(blog); } catch { Assert.Fail(); } }
public void InsertBlog() { _container = EntityContainer.InsertableContainer <Domain.Models.Blog> .ContainerConfig(); try { using (var scope = _container.BeginLifetimeScope()) { var insertableBlog = scope.Resolve <EntityService.Interfaces.IInsertable <Domain.Models.Blog> >(); var Blog = new Domain.Models.Blog() { Title = "test", ShortText = "test short text", ImageFileAddress = "test", TextFileAddress = "test file ", TimeToRead = 10, Writer = "test writer", Category = new Domain.DataAccess.MahourContext().CategoryTable.FirstOrDefault() }; insertableBlog.Insert(Blog); } } catch (Exception error) { Assert.Fail(error.Message); } }
public void Setup() { var context = new Domain.DataAccess.MahourContext(); _blog = context.BlogTable.FirstOrDefault(); if (_blog == null) { var Blog = new Domain.Models.Blog() { ID = DateTime.Now.Ticks.ToString(), Title = "test", ShortText = "test short text", ImageFileAddress = "test", TextFileAddress = "test file ", TimeToRead = 10, Writer = "test writer", Date = DateTime.Now, ReadCount = 0, Category = context.CategoryTable.FirstOrDefault() }; context.BlogTable.Add(Blog); context.SaveChanges(); _blog = Blog; } }
public void RemoveBlog() { _container = EntityContainer.RemoveableContainer.ContainerConfig <EntityService.Entities.Blog.ModifiableBlog>(_blog.ID); try { using (var scope = _container.BeginLifetimeScope()) { var removeableBlog = scope.Resolve <EntityService.Interfaces.IRemoveable>(); removeableBlog.Remove(); } } catch (Exception error) { Assert.Fail(error.Message); } finally { _blog = new Domain.DataAccess.MahourContext().BlogTable.FirstOrDefault(); } }
public SentPostViewModel( int id, string title, string content, string headerPhotoPath, DateTime sentDate, Domain.Models.Blog blog = null, Domain.Models.Category category = null, Domain.Models.Post approvedPost = null) { Id = id; Title = title; Content = content; HeaderPhotoPath = headerPhotoPath;; SentDate = sentDate.ToShortDateString(); IsApproved = approvedPost != null; if (blog != null) { Blog = new BlogViewModel(blog.Id, blog.Title); } if (category != null) { Category = new CategoryViewModel(category.Id, category.Title); } if (approvedPost != null) { ApprovedPost = new PostViewModel(approvedPost.Id, approvedPost.Title, approvedPost.Content, approvedPost.IsActive, approvedPost.HeaderPhotoFilePath, approvedPost.DatePublished, approvedPost.Blog, approvedPost.Category); } }
public PostViewModel( int id, string title, string content, bool isActive, string headerPhotoPath, DateTime publishDate, Domain.Models.Blog blog = null, Domain.Models.Category category = null) { Id = id; Title = title; Content = content; HeaderPhotoPath = headerPhotoPath; IsActive = isActive; Url = ContentUrlGenerator.GenerateUrl(id, title); PublishDate = publishDate.ToShortDateString(); if (blog != null) { Blog = new BlogViewModel(blog.Id, blog.Title); } if (category != null) { Category = new CategoryViewModel(category.Id, category.Title); } }