Ejemplo n.º 1
0
        public ActionResult SubmitTask(TasksViewModel model)
        {
            bool result = true;

            if (model.Comments == null)
            {
                model.Comments = new CommentViewModel[] { }
            }
            ;
            if (model.Id.HasValue)
            {
                result = TasksService.SaveTask(model.ToModel(), model.Comments.Select(x => x.ToModel()));
            }
            else
            {
                model.CreatedDate = DateTime.Now.ToString();
                result            = TasksService.CreateTask(model.ToModel(), model.Comments.Select(x => x.ToModel()));
            }

            if (result)
            {
                return(RedirectToAction("Index", "Home"));
            }
            return(View("Index", model));
        }