public IEnumerable <ProjectCommentViewModel> GetProjectComments(int projectId) { var models = new List <ProjectCommentViewModel>(); var coreModels = commentRepository.GetComments(projectId); foreach (var coreModel in coreModels) { models.Add(ProjectCommentMapper.MapProjectComment(coreModel)); } //order by date descending return(models.OrderByDescending(c => c.Date).AsEnumerable()); }
public ProjectCommentViewModel CreateProjectComment(ProjectCommentModel comment) { //map the incoming model to to a coreModel for insert var coreModel = ProjectCommentMapper.MapProjectCommentModel(comment); //insert the core model and return a core view var projectCommentView = commentRepository.CreateComment(coreModel); //map the core view to a model view var projectCommentViewModel = ProjectCommentMapper.MapProjectComment(projectCommentView); //return the model view return(projectCommentViewModel); }