Ejemplo n.º 1
0
        public ActionResult Create(Task task)
        {
            task.CreatedBy = (Guid)Membership.GetUser().ProviderUserKey;
            task.ModifieddBy = (Guid)Membership.GetUser().ProviderUserKey;
            task.CreateDate = DateTime.Now;
            task.ModificationDate = DateTime.Now;
            task.ActionDate = DateTime.Now;
            task.IsActive = true;
            if (ModelState.IsValid)
            {
              bool isStatusChanged=  unitOfWork.TaskRepository.InsertOrUpdate(task);
                AddAssignUser(task);
                AddFollower(task);
                AddLabel(task);
                unitOfWork.Save();
                SaveNotification(task, true, false, isStatusChanged);
                return RedirectToAction("ProjectTasks", new { @ProjectID = task.ProjectID });
            }
            List<SelectListItem> allUsers = GetAllUser(task.ProjectID);
            ViewBag.PossibleUsers = allUsers;
            ViewBag.PossibleProjects = unitOfWork.ProjectRepository.All;
            ViewBag.PossiblePriorities = unitOfWork.PriorityRepository.All;

            List<SelectListItem> allLabels = GetAllLabel();
            ViewBag.PossibleLabels = allLabels;
            GetAllStatus(task);
            return View(task); //return RedirectToAction("ProjectTasks", new { @ProjectID = task.ProjectID });
        }
Ejemplo n.º 2
0
        public ActionResult CreateFromKanban(long id)
        {
            Task task = new Task();
            task.ProjectID = id;
            ViewBag.PossibleProjects = unitOfWork.ProjectRepository.All;
            ViewBag.PossiblePriorities = unitOfWork.PriorityRepository.All;

            List<SelectListItem> allUsers = GetAllUser(task.ProjectID);
            ViewBag.PossibleUsers = allUsers;

            //task.SelectedAssignedUsers = task.Users.Select(u => u.UserId.ToString()).ToList();
            //task.SelectedFollowedUsers = task.Followers.Select(u => u.UserId.ToString()).ToList();
            //task.SelectedLabels = task.Labels.Select(u => u.LabelID.ToString()).ToList();
            List<string> statusList = new List<string>();
            if (!string.IsNullOrEmpty(task.Status))
            {
                statusList.Add(task.Status.ToString());
            }
            List<SelectListItem> allLabels = GetAllLabel();
            ViewBag.PossibleLabels = allLabels;

            GetAllStatus(task);

            MakeNotificationReadonly();

            return PartialView(task);
        }
Ejemplo n.º 3
0
        //
        // GET: /Tasks/Create?ProjectID=5
        public ActionResult Create(long ProjectID)
        {
            List<SelectListItem> allUsers = GetAllUser(ProjectID);
            ViewBag.PossibleUsers = allUsers;

            ViewBag.PossibleProjects = unitOfWork.ProjectRepository.All;
            ViewBag.PossiblePriorities = unitOfWork.PriorityRepository.All;

            List<SelectListItem> allLabels = GetAllLabel();
            ViewBag.PossibleLabels = allLabels;
            Task task = new Task();
            task.ProjectID = ProjectID;
            task.StartDate = DateTime.Now;
            task.EndDate = DateTime.Now;

            GetAllStatus(task);

            return View(task);
        }
Ejemplo n.º 4
0
        public ActionResult EditFromKanban(Task task)
        {
            task.ModifieddBy = (Guid)Membership.GetUser().ProviderUserKey;
            task.ModificationDate = DateTime.Now;
            task.ActionDate = DateTime.Now;
            if (ModelState.IsValid)
            {
                if (ValidTaskStatus(task))
                {
                    AddAssignUser(task);
                    AddFollower(task);
                    AddLabel(task);

                    bool isStatusChanged = unitOfWork.TaskRepository.InsertOrUpdate(task);
                    unitOfWork.Save();
                    if (task.ParentTaskId != null)
                    {
                        SaveNotification(task, false, true, isStatusChanged);
                    }
                    else
                    {
                        SaveNotification(task, false, false, isStatusChanged);
                    }
                    //return RedirectToAction("ProjectTasks", new { @ProjectID = task.ProjectID });
                }
                else
                {
                    TempData["Message"] = "One or more subtask is not closed yet!!!";
                }
            }

            List<SelectListItem> allUsers = GetAllUser(task.ProjectID);
            ViewBag.PossibleUsers = allUsers;
            ViewBag.PossibleProjects = unitOfWork.ProjectRepository.All;
            ViewBag.PossiblePriorities = unitOfWork.PriorityRepository.All;

            List<SelectListItem> allLabels = GetAllLabel();
            ViewBag.PossibleLabels = allLabels;
            GetAllStatus(task);
            return RedirectToAction("Kanban", new { @ProjectID = task.ProjectID });
        }
Ejemplo n.º 5
0
        private void UpdateAssignedUsers(Task task, Task existingTask)
        {
            var deletedUsers = existingTask.Users.ToList<UserProfile>();
            var addedUsers = task.Users.ToList<UserProfile>();
            deletedUsers.ForEach(c => existingTask.Users.Remove(c));
            foreach (UserProfile c in addedUsers)
            {

                if (context.Entry(c).State == System.Data.Entity.EntityState.Detached)
                    context.UserProfiles.Attach(c);
                existingTask.Users.Add(c);
            }
        }
Ejemplo n.º 6
0
        private void UpdateLabels(Task task, Task existingTask)
        {
            var deletedLabels = existingTask.Labels.ToList<Label>();
            var addedLabels = task.Labels.ToList<Label>();
            deletedLabels.ForEach(c => existingTask.Labels.Remove(c));
            foreach (Label c in addedLabels)
            {

                if (context.Entry(c).State == System.Data.Entity.EntityState.Detached)
                    context.Labels.Attach(c);
                existingTask.Labels.Add(c);
            }
        }
Ejemplo n.º 7
0
        //
        // GET: /Tasks/CreateSubTask?ProjectID=5&TaskID=1

        public ActionResult CreateSubTask(long ProjectID, long TaskID)
        {
            List<SelectListItem> allUsers = GetAllUser(ProjectID);
            ViewBag.PossibleUsers = allUsers;
            ViewBag.PossibleProjects = unitOfWork.ProjectRepository.All;
            ViewBag.PossiblePriorities = unitOfWork.PriorityRepository.All;
            ViewBag.PossibleSprints = unitOfWork.SprintRepository.AllByProjectID(ProjectID);

            List<SelectListItem> allLabels = GetAllLabel();
            ViewBag.PossibleLabels = allLabels;
            Task task = new Task();
            task.ProjectID = ProjectID;
            task.StartDate = DateTime.Now;
            task.EndDate = DateTime.Now;
            task.ParentTaskId = TaskID;
            task.ParentTask = unitOfWork.TaskRepository.Find(TaskID);
            GetAllStatus(task);
            return View(task);
        }
Ejemplo n.º 8
0
        private void GetAllStatus(Task task)
        {
            List<SelectListItem> statusList = new List<SelectListItem>();
            foreach (var item in Enum.GetValues(typeof(PMTool.Models.EnumCollection.TaskStatus)))
            {
                SelectListItem listitem = new SelectListItem();

                listitem.Value = Convert.ToString((int)item);
                listitem.Text = Enum.GetName(typeof(PMTool.Models.EnumCollection.TaskStatus), item).Replace("_", " ");
                if ((int)item == (int)task.Status)
                {
                    listitem.Selected = true;
                }
                else
                {
                    listitem.Selected = false;
                }
                statusList.Add(listitem);
            }

            ViewBag.PossibleTaskStatus = statusList;
        }
Ejemplo n.º 9
0
        public PartialViewResult EditFromKanban(Task task)
        {
            task.ModifiedBy = (Guid)Membership.GetUser().ProviderUserKey;
            task.ModificationDate = DateTime.Now;
            task.ActionDate = DateTime.Now;
            if (ModelState.IsValid)
            {
                AddAssignUser(task);
                AddFollower(task);
                AddLabel(task);

                bool isStatusChanged = unitOfWork.TaskRepository.InsertOrUpdate(task);
                unitOfWork.Save();
                if (task.ParentTaskId != null)
                {
                    SaveNotification(task, false, true, isStatusChanged);
                }
                else
                {
                    SaveNotification(task, false, false, isStatusChanged);
                }
            }

            List<SelectListItem> allUsers = GetAllUser(task.ProjectID);
            ViewBag.PossibleUsers = allUsers;
            ViewBag.PossibleProjects = unitOfWork.ProjectRepository.All;
            ViewBag.PossiblePriorities = unitOfWork.PriorityRepository.All;

            List<SelectListItem> allLabels = GetAllLabel();
            ViewBag.PossibleLabels = allLabels;
            GetAllStatus(task);

            Project project = unitOfWork.ProjectRepository.Find(task.ProjectID);
            ViewBag.CurrentProject = project;
            List<string> statusList = new List<string>();
            if (!string.IsNullOrEmpty(project.allStatus))
            {
                statusList = project.allStatus.Split(',').ToList();
            }
            ViewBag.AllStatus = statusList;
            List<Task> taskList = new List<Task>();
            taskList = unitOfWork.TaskRepository.ByProjectIncluding(task.ProjectID, t => t.Project).Include(t => t.Priority).Include(t => t.ChildTask).Include(t => t.Users).Include(t => t.Followers).Include(t => t.Labels).ToList();

               // return RedirectToAction("Kanban", new { @ProjectID = task.ProjectID });
            return PartialView("_Kanban", taskList);
        }
Ejemplo n.º 10
0
 private void GetAllStatus(Task task)
 {
     List<SelectListItem> statusList = new List<SelectListItem>();
     task.Project = unitOfWork.ProjectRepository.FindIncludingProjectStatus(task.ProjectID);
     //if (task.Project.ProjectStatuses!=null)
     //{
     //    foreach (ProjectStatus item in task.Project.ProjectStatuses)
     //    {
     //        SelectListItem listitem = new SelectListItem();
     //        listitem.Value = item.ProjectStatusID.ToString();
     //        listitem.Text = item.Name;
     //        if (item.ProjectStatusID == task.ProjectStatusID)
     //        {
     //            listitem.Selected = true;
     //        }
     //        else
     //        {
     //            listitem.Selected = false;
     //        }
     //        statusList.Add(listitem);
     //    }
     //}
     ViewBag.PossibleTaskStatus = task.Project.ProjectStatuses;
 }
Ejemplo n.º 11
0
        public bool InsertOrUpdate(Task task)
        {
            bool isStatusChanged = false;
            if (task.TaskID == default(long))
            {
                // New entity
                context.Tasks.Add(task);

            }
            else
            {
                // Existing entity
                var existingTask = context.Tasks.Include("Users")
                   .Where(t => t.TaskID == task.TaskID).FirstOrDefault<Task>();

                if (task.Status != existingTask.Status)
                {
                    isStatusChanged = true;
                }

                UpdateAssignedUsers(task, existingTask);

                UpdateFollowers(task, existingTask);

                UpdateLabels(task, existingTask);
                context.Entry(existingTask).CurrentValues.SetValues(task);

            }
            return isStatusChanged;
        }
Ejemplo n.º 12
0
 public ActionResult ShowEstimateView(Task task)
 {
     Task oldtask = unitOfWork.TaskRepository.Find(task.TaskID);
     oldtask.TaskHour = task.TaskHour;
     unitOfWork.TaskRepository.InsertOrUpdate(oldtask);
     unitOfWork.Save();
     List<Task> tasklist = unitOfWork.TaskRepository.GetTasksByProjectID(oldtask.ProjectID);
     return RedirectToAction("_TaskList", new { projectID = oldtask.ProjectID });
     //return RedirectToAction("ProjectTasks", new { projectID = oldtask.ProjectID });
 }
Ejemplo n.º 13
0
        private void SaveNotification(Task task, bool isTaskInsert, bool isSubTask, TaskPropertyChange change)
        {
            #region Old
            //string phrase = "";
            //if (task.Users.Count >0)
            //{
            //    foreach (User user in task.Users)
            //    {

            //        Notification notification = new Notification();
            //        if (isTaskInsert)
            //        {
            //            if (!isSubTask)
            //            {
            //                phrase = " Has assigned " + user.FirstName + " " + user.LastName + " on the Task --";
            //            }
            //            else
            //            {
            //                phrase = " Has assigned  " + user.FirstName + " " + user.LastName + "  on the Subtask --";
            //            }

            //            User createdUser = unitOfWork.UserRepository.GetUserByUserID(task.CreatedBy);
            //            notification.Title = createdUser.FirstName + " " + createdUser.LastName + phrase +" "+ task.Title;


            //        }
            //        else
            //        {
            //            User modifiedUser = unitOfWork.UserRepository.GetUserByUserID((int)Membership.GetUser(WebSecurity.CurrentUserName).ProviderUserKey);
            //            phrase = phrase + modifiedUser.FirstName + " " + modifiedUser.LastName + " ";
            //            if (!change.IsSatausChanged)
            //            {
            //                if (!isSubTask)
            //                {
            //                    phrase = phrase + " Has modify the Task --";
            //                }
            //                else
            //                {
            //                    phrase = phrase + " Has modify the Subtask --";
            //                }
            //            }
            //            else
            //            {
            //                string status = "";
            //                if (!isSubTask)
            //                {
            //                    if (task.ProjectStatusID != null)
            //                    {
            //                        ProjectStatus col = unitOfWork.ProjectStatusRepository.Find(Convert.ToInt64(task.ProjectStatusID));
            //                        status = col.Name;
            //                    }
            //                    phrase = phrase + string.Format(" Has changed the task status to {0} --", status);
            //                }
            //                else
            //                {
            //                    phrase = phrase + string.Format(" Has changed the subtask status to {0} --", status);
            //                }
            //            }

            //            if (!change.IsStartDateChanged)
            //            {
            //                string date = "";
            //                if (task.StartDate != null)
            //                {
            //                    date = task.StartDate.Value.ToShortDateString();
            //                }
            //                else
            //                {
            //                    date = "not defined";
            //                }
            //                if (!isSubTask)
            //                {

            //                    phrase = phrase + string.Format(" Has changed the task Start Date to {0} --", date);
            //                }
            //                else
            //                {
            //                    phrase = phrase + string.Format(" Has changed the subtask Start Date to {0} --", date);
            //                }
            //            }

            //            if (!change.IsEndtDateChanged)
            //            {
            //                string date = "";
            //                if (task.EndDate != null)
            //                {
            //                    date = task.EndDate.Value.ToShortDateString();
            //                }
            //                else
            //                {
            //                    date = "not defined";
            //                }
            //                if (!isSubTask)
            //                {

            //                    phrase = phrase + string.Format(" Has changed the task End Date to {0} --", date);
            //                }
            //                else
            //                {
            //                    phrase = phrase + string.Format(" Has changed the subtask End Date to {0} --", date);
            //                }
            //            }

            //            //User modifiedUser = unitOfWork.UserRepository.GetUserByUserID(task.ModifiedBy);
            //            notification.Title = phrase + task.Title;
            //        }
            //        notification.UserID = user.UserId;
            //        notification.Description = notification.Title;
            //        notification.ProjectID = task.ProjectID;
            //        notification.TaskID = task.TaskID;
            //        unitOfWork.NotificationRepository.InsertOrUpdate(notification);

            //        try
            //        {
            //            string logComment = phrase;
            //            logComment = logComment + "on " + DateTime.Now.ToShortDateString();
            //            TaskActivityLog log = unitOfWork.TaskActivityLogRepository.FindByTaskID(task.TaskID);
            //            if (log == null)
            //            {
            //                TaskActivityLog logNew = new TaskActivityLog();
            //                logNew.TaskID = task.TaskID;
            //                logNew.Comment = phrase;
            //                logNew.CreateDate = DateTime.Now;
            //                logNew.ModificationDate = DateTime.Now;
            //                unitOfWork.TaskActivityLogRepository.InsertOrUpdate(logNew);
            //                unitOfWork.Save();
            //            }
            //            else
            //            {
            //                log.Comment = log.Comment + " ; " + logComment;
            //                unitOfWork.Save();
            //            }
            //        }
            //        catch
            //        {
            //        }

            //        unitOfWork.Save();
            //    }
            //}
            //if (task.Followers.Count>0)
            //{
            //    foreach (User user in task.Followers)
            //    {
            //        Notification notification = new Notification();
            //        if (isTaskInsert)
            //        {
            //            if (!isSubTask)
            //            {
            //                phrase = " Has added  " + user.FirstName + " " + user.LastName + "  as a follower on the Task --";
            //            }
            //            else
            //            {
            //                phrase = " Has added  " + user.FirstName + " " + user.LastName + "  as a follower on the Subtask --";
            //            }
            //            User createdUser = unitOfWork.UserRepository.GetUserByUserID(task.CreatedBy);
            //            notification.Title = createdUser.FirstName + " " + createdUser.LastName + " " + phrase + task.Title;
            //        }
            //        else
            //        {
            //            if (!isSubTask)
            //            {
            //                phrase = " Has modify the Task --";
            //            }
            //            else
            //            {
            //                phrase = " Has modify the Subtask --";
            //            }
            //            User modifiedUser = unitOfWork.UserRepository.GetUserByUserID(task.ModifiedBy);
            //            notification.Title = modifiedUser.FirstName + " " + modifiedUser.LastName +" "+ phrase + task.Title;
            //        }

            //        if (!change.IsSatausChanged)
            //        {
            //            if (!isSubTask)
            //            {
            //                phrase = phrase + " Has modify the Task --";
            //            }
            //            else
            //            {
            //                phrase = phrase + " Has modify the Subtask --";
            //            }
            //        }
            //        else
            //        {
            //            string status = "";
            //            if (!isSubTask)
            //            {
            //                if (task.ProjectStatusID != null)
            //                {
            //                    ProjectStatus col = unitOfWork.ProjectStatusRepository.Find(Convert.ToInt64(task.ProjectStatusID));
            //                    status = col.Name;
            //                }
            //                phrase = phrase + string.Format(" Has changed the task status to {0} --", status);
            //            }
            //            else
            //            {
            //                phrase = phrase + string.Format(" Has changed the subtask status to {0} --", status);
            //            }
            //        }

            //        if (!change.IsStartDateChanged)
            //        {
            //            string date = "";
            //            if (task.StartDate != null)
            //            {
            //                date = task.StartDate.Value.ToShortDateString();
            //            }
            //            else
            //            {
            //                date = "not defined";
            //            }
            //            if (!isSubTask)
            //            {

            //                phrase = phrase + string.Format(" Has changed the task Start Date to {0} --", date);
            //            }
            //            else
            //            {
            //                phrase = phrase + string.Format(" Has changed the subtask Start Date to {0} --", date);
            //            }
            //        }

            //        if (!change.IsEndtDateChanged)
            //        {
            //            string date = "";
            //            if (task.EndDate != null)
            //            {
            //                date = task.EndDate.Value.ToShortDateString();
            //            }
            //            else
            //            {
            //                date = "not defined";
            //            }
            //            if (!isSubTask)
            //            {

            //                phrase = phrase + string.Format(" Has changed the task End Date to {0} --", date);
            //            }
            //            else
            //            {
            //                phrase = phrase + string.Format(" Has changed the subtask End Date to {0} --", date);
            //            }
            //        }

            //        notification.UserID = user.UserId;
            //        notification.Description = notification.Title;
            //        notification.ProjectID = task.ProjectID;
            //        notification.TaskID = task.TaskID;
            //        unitOfWork.NotificationRepository.InsertOrUpdate(notification);

            //        try
            //        {
            //            string logComment = phrase;
            //            logComment = logComment + "on " + DateTime.Now.ToShortDateString();
            //            TaskActivityLog log = unitOfWork.TaskActivityLogRepository.FindByTaskID(task.TaskID);
            //            if (log == null)
            //            {
            //                TaskActivityLog logNew = new TaskActivityLog();
            //                logNew.TaskID = task.TaskID;
            //                logNew.Comment = phrase;
            //                logNew.CreateDate = DateTime.Now;
            //                logNew.ModificationDate = DateTime.Now;
            //                unitOfWork.TaskActivityLogRepository.InsertOrUpdate(logNew);
            //                unitOfWork.Save();
            //            }
            //            else
            //            {
            //                log.Comment = log.Comment + " ; " + logComment;
            //                unitOfWork.Save();
            //            }
            //        }
            //        catch
            //        {
            //        }

            //        unitOfWork.Save();
            //    }
            //}
            //if (task.Users.Count == 0 && task.Followers.Count == 0)
            //{
            //    try
            //    {
            //        if (phrase != "")
            //        {
            //            User modifiedUser = unitOfWork.UserRepository.GetUserByUserID((int)Membership.GetUser(WebSecurity.CurrentUserName).ProviderUserKey);
            //            string logComment = phrase;
            //            logComment = logComment + "on " + DateTime.Now.ToShortDateString();
            //            TaskActivityLog log = unitOfWork.TaskActivityLogRepository.FindByTaskID(task.TaskID);
            //            if (log == null)
            //            {
            //                TaskActivityLog logNew = new TaskActivityLog();
            //                logNew.TaskID = task.TaskID;
            //                logNew.Comment = modifiedUser.FirstName + " " + modifiedUser.LastName + " Created the task " + task.Title + " on " + DateTime.Now.ToShortDateString();
            //                logNew.CreateDate = DateTime.Now;
            //                logNew.ModificationDate = DateTime.Now;
            //                unitOfWork.TaskActivityLogRepository.InsertOrUpdate(logNew);
            //                unitOfWork.Save();
            //            }
            //            else
            //            {
            //                log.Comment = log.Comment + " ; " + logComment;
            //                unitOfWork.Save();
            //            }
            //        }
            //    }
            //    catch
            //    {
            //    }
            //}
            #endregion

            # region if Insert
Ejemplo n.º 14
0
 private void AddFollower(Task task)
 {
     task.Followers = new List<User>();
     if (task.SelectedFollowedUsers != null)
     {
         foreach (string userID in task.SelectedFollowedUsers)
         {
             User user = unitOfWork.UserRepository.GetUserByUserID(new Guid(userID));
             task.Followers.Add(user);
         }
     }
 }
Ejemplo n.º 15
0
 public Task Find(long id)
 {
     Task objTask = new Task();
     //return 
     objTask = context.Tasks.Where(t => t.TaskID == id).Include(task => task.Users).Include(task => task.Followers).Include(task => task.CreatedByUser).FirstOrDefault();
     objTask.CreatedByUser = context.UserProfiles.Where(t => t.UserId == objTask.CreatedBy).FirstOrDefault();
     objTask.ProjectStatus = context.ProjectStatuses.Where(t => t.ProjectStatusID == objTask.ProjectStatusID).FirstOrDefault();
     return objTask;
 }
Ejemplo n.º 16
0
 private void AddLabel(Task task)
 {
     task.Labels = new List<Label>();
     if (task.SelectedLabels != null)
     {
         foreach (string labelID in task.SelectedLabels)
         {
             Label label = unitOfWork.LabelRepository.Find(Convert.ToInt64(labelID));
             task.Labels.Add(label);
         }
     }
 }
Ejemplo n.º 17
0
        public TaskPropertyChange InsertOrUpdate(Task task)
        {
            TaskPropertyChange change = new TaskPropertyChange();
           //bool isStatusChanged = false;
            if (task.TaskID == default(long))
            {
                // New entity
                context.Tasks.Add(task);

            }
            else
            {
                // Existing entity
                var existingTask = context.Tasks.Include("Users")
                   .Where(t => t.TaskID == task.TaskID).FirstOrDefault<Task>();

                if (task.ProjectStatusID != existingTask.ProjectStatusID)
                {
                    change.IsSatausChanged = true;
                    if (existingTask.ProjectStatusID == null)
                    {
                        change.FromSataus = "undefined";
                    }
                    else
                    {
                        ProjectStatus stat = context.ProjectStatuses.Where(s => s.ProjectStatusID == existingTask.ProjectStatusID).FirstOrDefault();
                        change.FromSataus = stat.Name;
                    }
                    if (task.ProjectStatusID == null)
                    {
                        change.ToStatus = "undefined";
                    }
                    else
                    {
                        ProjectStatus stat = context.ProjectStatuses.Where(s => s.ProjectStatusID == task.ProjectStatusID).FirstOrDefault();
                        change.ToStatus = stat.Name;
                    }
                }
                if (task.StartDate != existingTask.StartDate)
                {
                    change.IsStartDateChanged = true;
                    
                    change.FromSatrtDate = existingTask.StartDate;
                    
                    change.ToSatrtDate = task.StartDate;
                    
                }
                if (task.EndDate != existingTask.EndDate)
                {
                    change.IsEndtDateChanged = true;

                    change.FromEndDate = existingTask.EndDate;

                    change.ToEndDate = task.EndDate;
                }
                UpdateAssignedUsers(task, existingTask);

                UpdateFollowers(task, existingTask);

                UpdateLabels(task, existingTask);
                context.Entry(existingTask).CurrentValues.SetValues(task);

                ImplementDragDropRules(task);

            }
            return change;
        }
Ejemplo n.º 18
0
        private void SaveNotification(Task task, bool isTaskInsert,bool isSubTask,bool isTaskStatusChanged)
        {
            string phrase = "";
            if (task.Users != null)
            {
                foreach (User user in task.Users)
                {
                    Notification notification = new Notification();
                    if (isTaskInsert)
                    {
                        if (!isSubTask)
                        {
                            phrase = " Has assigned you on the Task --";
                        }
                        else
                        {
                            phrase = " Has assigned you on the Subtask --";
                        }

                        User createdUser = unitOfWork.UserRepository.GetUserByUserID(task.CreatedBy);
                        notification.Title = createdUser.FirstName + " " + createdUser.LastName + phrase + task.Title;
                    }
                    else
                    {
                        if (!isTaskStatusChanged)
                        {
                            if (!isSubTask)
                            {
                                phrase = " Has modify the Task --";
                            }
                            else
                            {
                                phrase = " Has modify the Subtask --";
                            }
                        }
                        else
                        {
                            if (!isSubTask)
                            {
                                phrase = string.Format(" Has changed the task status to {0} --",task.Status.ToString());
                            }
                            else
                            {
                                phrase = string.Format(" Has changed the subtask status to {0} --",task.Status.ToString());
                            }
                        }
                        User modifiedUser = unitOfWork.UserRepository.GetUserByUserID(task.ModifieddBy);
                        notification.Title = modifiedUser.FirstName + " " + modifiedUser.LastName + phrase + task.Title;
                    }
                    notification.UserID = user.UserId;
                    notification.Description = notification.Title;
                    notification.ProjectID = task.ProjectID;
                    notification.TaskID = task.TaskID;
                    unitOfWork.NotificationRepository.InsertOrUpdate(notification);
                    unitOfWork.Save();
                }
            }
            if (task.Followers != null)
            {
                foreach (User user in task.Followers)
                {
                    Notification notification = new Notification();
                    if (isTaskInsert)
                    {
                        if (!isSubTask)
                        {
                            phrase = " Has added you as a follower on the Task --";
                        }
                        else
                        {
                            phrase = " Has added you as a follower on the Subtask --";
                        }
                        User createdUser = unitOfWork.UserRepository.GetUserByUserID(task.CreatedBy);
                        notification.Title = createdUser.FirstName + " " + createdUser.LastName + phrase + task.Title;
                    }
                    else
                    {
                        if (!isSubTask)
                        {
                            phrase = " Has modify the Task --";
                        }
                        else
                        {
                            phrase = " Has modify the Subtask --";
                        }
                        User modifiedUser = unitOfWork.UserRepository.GetUserByUserID(task.ModifieddBy);
                        notification.Title = modifiedUser.FirstName + " " + modifiedUser.LastName + phrase + task.Title;
                    }
                    notification.UserID = user.UserId;
                    notification.Description = notification.Title;
                    notification.ProjectID = task.ProjectID;
                    notification.TaskID = task.TaskID;
                    unitOfWork.NotificationRepository.InsertOrUpdate(notification);
                    unitOfWork.Save();
                }
            }
        }
Ejemplo n.º 19
0
 private Task ImplementDragDropRules(Task task)
 {
     List<ProjectStatusRule> rules = context.ProjectStatusRules.Where(r => r.ProjectID == task.ProjectID).ToList();
     foreach (ProjectStatusRule rule in rules)
     {
         if (task.ProjectStatusID == rule.ProjectStatusID)
         context.Entry(task).Property(rule.DateMaper.ToString().Replace("_","")).CurrentValue = DateTime.Now;
     }
     return task;
 }
Ejemplo n.º 20
0
 private bool ValidTaskStatus(Task task)
 {
     bool isvalid = true;
     if (task.Status == PMTool.Models.EnumCollection.TaskStatus.Closed)
     {
         List<Task> subTaskList = unitOfWork.TaskRepository.AllSubTaskByProjectIncluding(task.ProjectID, task.TaskID, t => t.Project).Include(t => t.Priority).Include(t => t.ChildTask).Include(t => t.Users).Include(t => t.Followers).Include(t => t.Labels).ToList();
         if (subTaskList.Any(st => st.Status != PMTool.Models.EnumCollection.TaskStatus.Closed))
         {
             isvalid = false;
         }
     }
     return isvalid;
 }
Ejemplo n.º 21
0
        //
        // GET: /Tasks/Create?ProjectID=5

        public ActionResult Create(long ProjectID)
        {
            List<SelectListItem> allUsers = GetAllUser(ProjectID);
            ViewBag.PossibleUsers = allUsers;

            ViewBag.PossibleProjects = unitOfWork.ProjectRepository.All;
            ViewBag.PossiblePriorities = unitOfWork.PriorityRepository.All;
            ViewBag.PossibleSprints = unitOfWork.SprintRepository.AllByProjectID(ProjectID);
            List<SelectListItem> allLabels = GetAllLabel();
            ViewBag.PossibleLabels = allLabels;
            Task task = new Task();
            task.ProjectID = ProjectID;
            task.TaskUID = "T" + unitOfWork.TaskRepository.All.Where(p => p.ProjectID == ProjectID).Count().ToString();
            //task.StartDate = DateTime.Now;
            //task.EndDate = DateTime.Now;

            GetAllStatus(task);

            return View(task);
        }