Exemplo n.º 1
0
        public ActionResult CommentEdit(int commentID)
        {
            EnhancementUserComment          userCommentModel = Repository.EnhancementComments.GetByID(commentID);
            EnhancementCommentEditViewModel viewModel        = BuildCommentEditViewModel(null, userCommentModel);

            //return View(viewModel);
            var results = RenderPartialViewToString("_CommentEdit", viewModel);

            return(Json(new { success = true, message = results }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        private EnhancementCommentEditViewModel BuildCommentEditViewModel(EnhancementCommentEditViewModel viewModel, EnhancementUserComment userCommentModel)
        {
            if (viewModel == null)
            {
                viewModel              = new EnhancementCommentEditViewModel();
                viewModel.AccountName  = String.Empty;
                viewModel.AccountEmail = String.Empty;
                if (userCommentModel == null)
                {
                    userCommentModel                = new EnhancementUserComment();
                    userCommentModel.ID             = 0;
                    userCommentModel.AccountID      = 0;
                    userCommentModel.RegulatorID    = 0;
                    userCommentModel.OrganizationID = 0;
                    userCommentModel.UserPriorityID = 0;
                }
                viewModel.UserComment = userCommentModel;
            }
            if (userCommentModel.AccountID > 0)
            {
                string name;
                string email;
                Repository.Enhancements.AccountNameEmail(userCommentModel.AccountID, out name, out email);
                viewModel.AccountName  = name;
                viewModel.AccountEmail = email;
            }
            else
            {
                viewModel.AccountName  = CurrentAccount.FirstName + " " + CurrentAccount.LastName;
                viewModel.AccountEmail = CurrentAccount.Email;
            }

            viewModel.Regulators = (from r in Repository.Regulators.Search(accountID: Repository.ContextAccountID).ToList()
                                    select new SelectListItem
            {
                Value = r.ID.ToString(),
                Text = r.NameShort
            }).ToList();
            viewModel.Organizations = (from o in Repository.Organizations.GetByAccount(Repository.ContextAccountID)
                                       select new SelectListItem
            {
                Value = o.ID.ToString(),
                Text = o.Name
            }).ToList();

            viewModel.Priorities = (from p in Repository.Enhancements.Priorities
                                    select new SelectListItem
            {
                Value = p.ID.ToString(),
                Text = p.Name
            }).ToList();
            return(viewModel);
        }
Exemplo n.º 3
0
        public ActionResult CommentDelete(int commentID)
        {
            EnhancementUserComment comment = null;

            comment = Repository.EnhancementComments.GetByID(commentID);
            if (comment != null &&
                (comment.AccountID == CurrentAccountID /*|| CurrentUserRoles.IsEnhancementAdmin*/))
            {
                Repository.EnhancementComments.Delete(comment);
                return(Json(new { success = true }));
            }
            else
            {
                //return RedirectToAction("Index");
                return(Json(new { success = false }));
            }
        }
Exemplo n.º 4
0
        public ActionResult CommentEdit(int commentID, EnhancementCommentEditViewModel enhancementCommentEditViewModel)
        {
            EnhancementUserComment comment = null;

            if (enhancementCommentEditViewModel != null)
            {
                comment = Repository.EnhancementComments.GetByID(commentID);
            }
            if (comment != null &&
                (comment.AccountID == CurrentAccountID /*|| CurrentUserRoles.IsEnhancementAdmin*/))
            {
                enhancementCommentEditViewModel.UpdateModel(comment);
                Repository.EnhancementComments.Update(comment);
                //return RedirectToAction("Detail", new { id = enhancementCommentEditViewModel.UserComment.EnhancementID });
                return(Json(new { success = true }));
            }
            else
            {
                //return RedirectToAction("Index");
                return(Json(new { success = false }));
            }
        }