private static void InitializeAutoMapper() { Mapper.Initialize( cfg => cfg.CreateMap <Postdb, Post>() .AfterMap((s, d) => { //Author IStudentDbRepository <Studentdb> rStudents = new StudentDbRepository(); Studentdb studentdb = rStudents.Get(s.StudentId); d.Author = $"{studentdb.FirstName} {studentdb.LastName}"; //Commentsdb ICommentDbRepository <Commentdb> rCommentsdb = new CommentDbRepository(); IEnumerable <Commentdb> commentsdb = rCommentsdb.GetAll(s.Id); // List <Comment> comments = new List <Comment>(); //Commentdb+Author foreach (var commentdb in commentsdb) { Comment comment = new Comment() { Id = commentdb.Id, Content = commentdb.Content, Created = commentdb.Created }; Studentdb student = rStudents.Get(commentdb.StudentId); comment.Author = $"{student.FirstName} {student.LastName}"; comments.Add(comment); } // d.Comments = comments; //Tags ITagDbRepository <Tagdb> rTags = new TagDbRepository(); d.Tags = rTags.GetAll(s.Id); })); }
public void SetUp() { _repository = new CommentDbRepository(); }
public void SetUp() { _repository = new CommentDbRepository(); }