Example #1
0
        public ActionResult UpdateEmployee(int subtaskId, int userId)
        {
            var subtask = TaskBO.AssignTaskGetById(subtaskId);

            if (subtask == null)
            {
                return(RedirectToAction("NotFound", "Home"));
            }
            subtask.UserId = userId;
            TaskBO.AssignTaskUpdate(subtask);
            return(RedirectToAction("Index", new { id = subtaskId }));
        }
Example #2
0
        public ActionResult Edit(AssignTask assignTask)
        {
            var assignTaskSave = TaskBO.AssignTaskGetById(assignTask.Id);

            if (assignTaskSave == null)
            {
                return(RedirectToAction("NotFound", "Home"));
            }

            if (assignTaskSave.UserId > 0)
            {
                assignTaskSave.UserId      = assignTask.UserId;
                assignTaskSave.Requirement = assignTask.Requirement;
                assignTaskSave.ModifyBy    = CurrentUser.Id;
                assignTaskSave.ModifyDate  = DateTime.Now;

                if (!string.IsNullOrEmpty(assignTask.StartAndEndDate) && assignTask.StartAndEndDate.Split('-').Length == 2)
                {
                    var      strStart = assignTask.StartAndEndDate.Split('-')[0].Trim();
                    var      strEnd   = assignTask.StartAndEndDate.Split('-')[1].Trim();
                    DateTime sdate;
                    DateTime edate;
                    if (DateTime.TryParseExact(strStart, Helper.FormatDate,
                                               new CultureInfo("en-US"),
                                               DateTimeStyles.None,
                                               out sdate))
                    {
                        assignTask.StartDate = sdate;
                    }

                    if (DateTime.TryParseExact(strEnd, Helper.FormatDate,
                                               new CultureInfo("en-US"),
                                               DateTimeStyles.None,
                                               out edate))
                    {
                        assignTask.EndDate = edate;
                    }

                    TaskBO.AssignTaskUpdate(assignTask);
                }
                return(RedirectToAction("Index", new { id = assignTaskSave.TaskId }));
            }

            ViewBag.Task  = TaskBO.GetById(assignTask.TaskId);
            ViewBag.Users = UserBO.GetByDepartmentId(CurrentUser.DepartmentLeader);
            return(View("Create", assignTask));
        }