Example #1
0
        public ActionResult Create(TaskViewModel model)
        {
            Guid userId;
            if (!Guid.TryParse(System.Web.HttpContext.Current.User.Identity.GetUserId(), out userId))
            {
                return View();
            }

            if (ModelState.IsValid)
            {
                var user = _userManager.FindById(userId);
                _taskService.Save(new Task
                {
                    Name = model.Name,
                    DateEnd = model.DateEnd,
                    Status = TaskStatus.New,
                    AssignedToUser = user,
                    Created = _dateService.GetCurrentDateUtc(),
                    CreatedBy = user
                });

                return RedirectToAction("Index");
            }

            return View(model);
        }
Example #2
0
        // GET: Tasks/Details/5
        public ActionResult Details(Guid? id)
        {
            Guid userId;
            if (!Guid.TryParse(System.Web.HttpContext.Current.User.Identity.GetUserId(), out userId))
            {
                return View();
            }

            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            var task = _taskService.FindById(id.Value, userId);
            if (task == null)
            {
                return HttpNotFound();
            }

            var model = new TaskViewModel
            {
                Id = task.Id,
                DateEnd = task.DateEnd,
                Name = task.Name,
                Status = task.Status ?? TaskStatus.None
            };

            return View(model);
        }
Example #3
0
        public ActionResult Edit(TaskViewModel model)
        {
            Guid userId;
            if (!Guid.TryParse(System.Web.HttpContext.Current.User.Identity.GetUserId(), out userId))
            {
                return View();
            }

            if (ModelState.IsValid)
            {
                var task = _taskService.FindById(model.Id, userId);
                task.DateEnd = model.DateEnd;
                task.Name = model.Name;
                task.Status = model.Status;

                _taskService.Save(task);

                return RedirectToAction("Index");
            }

            return View(model);
        }