Пример #1
0
        public ActionResult Delete(SaveCommentVM model)
        {
            Comment item = commentsRepo.GetById(model.Id);

            commentsRepo.Delete(item);
            return(RedirectToAction("Details", "TasksManagement", new { id = model.ParentTaskId }));
        }
Пример #2
0
        public ActionResult Delete(int id)
        {
            SaveCommentVM model = new SaveCommentVM();
            Comment       item  = commentsRepo.GetById(id);

            if (model == null)
            {
                return(RedirectToAction("Details", "TasksManagement", new { id = model.ParentTaskId }));
            }
            PopulateItem(model, item);
            return(View(model));
        }
Пример #3
0
        public ActionResult Edit(int?id, int parentTaskId)
        {
            UsersRepository usersRepo = new UsersRepository();
            SaveCommentVM   model     = new SaveCommentVM();
            Comment         item      = null;

            if (id == null)
            {
                item = new Comment();
            }
            else
            {
                item = commentsRepo.GetById(id.Value);
            }
            PopulateItem(model, item);
            model.Users = usersRepo.GetAll();
            return(View(model));
        }
Пример #4
0
        public ActionResult Edit(SaveCommentVM model)
        {
            UsersRepository usersRepo = new UsersRepository();
            Comment         item      = null;

            if (model.Id <= 0)
            {
                item = new Comment();
            }
            else
            {
                item = commentsRepo.GetById(model.Id);
            }

            PopulateViewModel(item, model);
            model.Users = usersRepo.GetAll();
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            commentsRepo.Save(item);
            return(RedirectToAction("Details", "TasksManagement", new { id = model.ParentTaskId }));
        }
Пример #5
0
 public void PopulateViewModel(Comment item, SaveCommentVM model)
 {
     item.AssignedUserId = model.AssignedUserId;
     item.CommentContent = model.CommentContent;
     item.ParentTaskId   = model.ParentTaskId;
 }
Пример #6
0
 public void PopulateItem(SaveCommentVM model, Comment item)
 {
     model.AssignedUserId = item.AssignedUserId;
     model.CommentContent = item.CommentContent;
     model.ParentTaskId   = item.ParentTaskId;
 }