示例#1
0
        public ActionResult Edit(UserTaskManageViewModel model)
        {
            if (ModelState.IsValid)
            {
                var application = userTaskRepository.GetById(model.Id);
                if (application == null)
                {
                    throw new ArgumentException(string.Format("UserTask with Id [{0}] does not exist", model.Id));
                }

                try
                {
                    model.ToDalEntity(application);
                    userTaskRepository.UpdateAndSubmit(application);

                    base.SetSuccessMessage("The user task [{0}] has been updated.", application.Name);
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    base.SetErrorMessage("Whoops! Couldn't update the application. The error was [{0}]", ex.Message);
                }
            }

            return(View(model));
        }
示例#2
0
        public ActionResult Create(UserTaskManageViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var userTask = model.ToDalEntity();
                    userTaskRepository.InsertAndSubmit(userTask);

                    base.SetSuccessMessage("The userTask [{0}] has been created.", userTask.Name);
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    base.SetErrorMessage("Whoops! Couldn't create the new userTask. The error was [{0}]", ex.Message);
                }
            }
            return(View(model));
        }