예제 #1
0
        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());
        }
예제 #2
0
        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);
        }