public IHttpActionResult CommentProjectById(int projectId, [FromBody] ProjectCommentViewModel commentModel)
        {
            var project = _projectService.GetProjectById(projectId);

            _userService.SendCommentToUser(project.SubmissionUser, $"Athugasemd vegna {project.ProjectName} - Hljóðrit.is", commentModel.Comment);
            return(Ok());
        }
Beispiel #2
0
        public static ProjectCommentViewModel MapProjectComment(ProjectCommentView projectComment)
        {
            var model = new ProjectCommentViewModel();

            model.Id        = projectComment.Id;
            model.AreaId    = projectComment.AreaId;
            model.Area      = projectComment.Area;
            model.TypeId    = projectComment.TypeId;
            model.Type      = projectComment.Type;
            model.ProjectId = projectComment.ProjectId;
            model.Date      = projectComment.Date.GetMyLocalTime();
            model.Text      = projectComment.Text;
            model.Writer    = projectComment.Writer;
            model.MyComment = projectComment.UserId == IdentityContext.Current.User.Id;
            return(model);
        }
Beispiel #3
0
        public ProjectCommentViewModel GetProjectComment(int id)
        {
            var projectComment = _dbContext.ProjectComments
                                 .Include(pr => pr.Project)
                                 .Include(u => u.User)
                                 .SingleOrDefault(p => p.Id == id);

            if (projectComment == null)
            {
                return(null);
            }

            var projectCommentViewAllModel = new ProjectCommentViewModel(
                projectComment.Id,
                projectComment.Content,
                projectComment.Project.Title,
                projectComment.User.FullName
                );

            return(projectCommentViewAllModel);
        }
Beispiel #4
0
        public async Task <ActionResult> Create(ProjectCommentViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var user   = _userManager.FindById(User.Identity.GetUserId());
                var myUser = db.Users.Where(x => x.AspNetUsersId.Equals(user.Id)).FirstOrDefault();

                var comment = new UserProjectComment()
                {
                    ProjectId    = viewModel.ProjectId,
                    Text         = viewModel.Text,
                    BackerId     = myUser.Id,
                    DateInserted = DateTime.Now
                };
                db.UserProjectComments.Add(comment);
                await db.SaveChangesAsync();

                return(RedirectToAction("Details", "Project", new { id = viewModel.ProjectId }));
            }

            return(View(viewModel));
        }