Пример #1
0
        public ActionResult Create(FormCollection collection)
        {
            TaskModel task = new TaskModel();
            task.Title = collection["Title"];
            task.Description = collection["Description"];
            task.StatusId = int.Parse(collection["StatusId"]);
            try
            {
                if (collection["StartDate"] != null)
                    task.StartDate = DateTime.Parse(collection["StartDate"]);
            }
            catch (FormatException)
            {
                task.StartDate = DateTime.Today;
            }
            if (collection["EndDate"] != null)
                task.EndDate = DateTime.Parse(collection["EndDate"]);

            TaskUtility.CreateTask(task.Title, task.Description, task.StatusId, task.StartDate, task.EndDate);

            return RedirectToAction("Active");
        }
Пример #2
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            TaskModel task = new TaskModel();
            task.Title = collection["Title"];
            task.Description = collection["Description"];
            task.StatusId = int.Parse(collection["StatusId"]);

            if (collection["StartDate"] != null)
            {
                task.StartDate = DateTime.Parse(collection["StartDate"]);
                UserTasksUtility.UpdateUsersTaskDate(id, task.StartDate.Value);
            }

            TaskUtility.UpdateTask(id, task.Title, task.Description, task.StatusId, task.StartDate);

            return RedirectToAction("Active");
        }