Пример #1
0
 //
 // GET: /Projects/Create
 public ActionResult Create()
 {
     List<SelectListItem> allUsers = GetAllUser();
     ViewBag.PossibleUsers = allUsers;
     Project project = new Project();
     project.allStatus = "";
     return View(project);
 }
Пример #2
0
        //
        // GET: /Projects/Create

        public ActionResult Create()
        {
            List<SelectListItem> allUsers = GetAllUser();
            ViewBag.PossibleUsers = allUsers;
            Project project = new Project();

            /*To add Close status by default. Added by: Mahedee @06-03-14*/
            if (project.ProjectStatuses == null)
            {
                List<ProjectStatus> lstStatus = new List<ProjectStatus>();
                lstStatus.Add(new ProjectStatus { Name = "Closed", ProjectStatusID = 1});
                project.ProjectStatuses = lstStatus;
                project.allStatus = "Closed";
            }

            return View(project);
        }
Пример #3
0
        public ActionResult Create(Project project)
        {
            project.ModificationDate = DateTime.Now;
            project.CreateDate = DateTime.Now;
            project.ActionDate = DateTime.Now;
            project.CreatedBy = (Guid)Membership.GetUser().ProviderUserKey;
            project.ModifieddBy = (Guid)Membership.GetUser().ProviderUserKey;

            if (ModelState.IsValid)
            {
                unitOfWork.ProjectRepository.InsertOrUpdate(project);
                AddAssignUser(project);
                unitOfWork.Save();
                SaveNotification(project,true);

                return RedirectToAction("Index");
            }
            List<SelectListItem> allUsers = GetAllUser();
            ViewBag.PossibleUsers = allUsers;
            return View(project);
        }
Пример #4
0
        private List<User> UpdateAssignedUsers(Project project, Project existingProject)
        {
            List<User> userList = new List<User>();
            var deletedUsers = existingProject.Users.ToList<User>();
            var addedUsers = project.Users.ToList<User>();
               // deletedUsers.ForEach(c => existingProject.Users.Remove(c));
            foreach (User user in existingProject.Users.ToList())
            {
                List<Task> taskList = context.Tasks.Include("Users").Where(t => t.Users.Any(u=>u.UserId==user.UserId)).ToList();
               if (taskList.Count == 0)
                   existingProject.Users.Remove(user);
               else
                   userList.Add(user);
            }
            foreach (User c in addedUsers)
            {

                if (context.Entry(c).State == System.Data.Entity.EntityState.Detached)
                    context.Users.Attach(c);
                existingProject.Users.Add(c);
            }
            return userList;
        }
Пример #5
0
        public List<User> InsertOrUpdate(Project project)
        {
            List<User> userList = new List<User>();
            if (project.ProjectID == default(long)) {
                // New entity
                context.Projects.Add(project);
            } else {
                // Existing entity
                var existingProject = context.Projects.Include("Users")
                    .Where(t => t.ProjectID == project.ProjectID).FirstOrDefault<Project>();

                userList = UpdateAssignedUsers(project, existingProject);
                context.Entry(existingProject).CurrentValues.SetValues(project);
            }
            return userList;
        }
Пример #6
0
        public ActionResult Edit(Project project)
        {
            project.ModificationDate = DateTime.Now;
            project.ActionDate = DateTime.Now;
            project.ModifieddBy = (Guid)Membership.GetUser().ProviderUserKey;
            List<User> userList = new List<User>();
            if (ModelState.IsValid)
            {
                AddAssignUser(project);
               userList= unitOfWork.ProjectRepository.InsertOrUpdate(project);
                unitOfWork.Save();
                SaveNotification(project, false);
                string msg = "";
                foreach (User user in userList)
                {
                    msg = msg + user.FirstName + " " + user.LastName + ", ";
                }
                msg = msg + " user(s) are assigned in one or more task in this project;";
                if (msg != string.Empty)
                {
                    TempData["Message"]= msg;
                }
                return RedirectToAction("Index");

            }
            List<SelectListItem> allUsers = GetAllUser();
            ViewBag.PossibleUsers = allUsers;
               // project.SelectedAssignedUsers = project.Users.Select(u => u.UserId.ToString()).ToList();
            return View(project);
        }
Пример #7
0
        private void SaveNotification(Project project,bool isProjectInsert)
        {
            if (project.Users != null)
            {
                foreach (User user in project.Users)
                {

                    Notification notification = new Notification();
                    if (isProjectInsert)
                    {
                        User createdUser = unitOfWork.UserRepository.GetUserByUserID(project.CreatedBy);
                        notification.Title = createdUser.FirstName + " " + createdUser.LastName + " Has added you on the porject --" + project.Name;
                    }
                    else
                    {
                        User modifiedUser = unitOfWork.UserRepository.GetUserByUserID(project.ModifieddBy);
                        notification.Title = modifiedUser.FirstName + " " + modifiedUser.LastName + " Has modify the porject --" + project.Name;
                    }
                    notification.UserID = user.UserId;
                    notification.Description = notification.Title;
                    notification.ProjectID = project.ProjectID;
                    unitOfWork.NotificationRepository.InsertOrUpdate(notification);
                    unitOfWork.Save();
                }
            }
        }
Пример #8
0
        private void AddAssignUser(Project project)
        {
            project.Users = new List<User>();
            if (project.SelectedAssignedUsers != null)
            {
                foreach (string userID in project.SelectedAssignedUsers)
                {
                    User user = unitOfWork.UserRepository.GetUserByUserID(new Guid(userID));
                    project.Users.Add(user);

                }
            }
        }
Пример #9
0
        private void GetTaskList(long projectID, out List<Task> taskList, out Project project)
        {
            taskList = new List<Task>();
            UserProfile user = unitOfWork.UserRepository.GetUserByUserID((int)Membership.GetUser(WebSecurity.CurrentUserName).ProviderUserKey);
            project = unitOfWork.ProjectRepository.Find(projectID);
            //If this project is created by the current user. Then he can see all task.
            if (project.CreatedBy == user.UserId)
                taskList = unitOfWork.TaskRepository.ByProjectIncluding(projectID, task => task.Project).Include(task => task.Priority).Include(task => task.ChildTask).Include(task => task.Users).Include(task => task.Followers).Include(task => task.Labels).ToList();

            //If this project is owned by the current user. Then he can see all task.
            else if (project.ProjectOwners.Contains(user))
                taskList = unitOfWork.TaskRepository.ByProjectIncluding(projectID, task => task.Project).Include(task => task.Priority).Include(task => task.ChildTask).Include(task => task.Users).Include(task => task.Followers).Include(task => task.Labels).ToList();

            else
                taskList = unitOfWork.TaskRepository.ByProjectIncluding(projectID, user, task => task.Project).Include(task => task.Priority).Include(task => task.ChildTask).Include(task => task.Users).Include(task => task.Followers).Include(task => task.Labels).ToList();

        }
Пример #10
0
        private void AddProjectStatus(Project project)
        {
            unitOfWork.ProjectStatusRepository.DeletebyProjectID(project.ProjectID);

            List<string> statuses = new List<string>();
            if (!string.IsNullOrEmpty(project.allStatus))
            {
                statuses = project.allStatus.Split(',').Distinct().ToList();
                foreach (string status in statuses)
                {
                    if (!string.IsNullOrEmpty(status))
                    {
                        ProjectStatus col = new ProjectStatus();
                        col.Name = status;
                        col.ProjectID = project.ProjectID;
                        unitOfWork.ProjectStatusRepository.InsertOrUpdate(col);
                    }
                }
            }
        }
Пример #11
0
        public ActionResult Edit(Project project)
        {
            project.ModificationDate = DateTime.Now;
            project.ActionDate = DateTime.Now;
            project.ModifiedBy = (int)Membership.GetUser().ProviderUserKey;
            project.IsActive = true;
            List<UserProfile> userList = new List<UserProfile>();
            if (ModelState.IsValid)
            {
                AddAssignUser(project);
                AddProjectOwner(project);
                AddProjectStatus(project);
               userList= unitOfWork.ProjectRepository.InsertOrUpdate(project);
               project.allStatus = "";
                unitOfWork.Save();
                SaveNotification(project, false);
                string msg = "";
                foreach (UserProfile user in userList)
                {
                    msg = msg + user.FirstName + " " + user.LastName + ", ";
                }
                msg = msg + " user(s) are assigned in one or more task in this project;";
                if (msg != string.Empty)
                {
                    TempData["Message"]= msg;
                }
                return RedirectToAction("Index");
                
            }
            List<SelectListItem> allUsers = GetAllUser();
            ViewBag.PossibleUsers = allUsers;
            return View(project);

        }
Пример #12
0
        //
        // GET: /Projects/Edit/5

        public ActionResult Edit(long id)
        {
            Project project = new Project();
             project = unitOfWork.ProjectRepository.Find(id);
             project.allStatus = "";
            List<SelectListItem> allUsers = GetAllUser();
            ViewBag.PossibleUsers = allUsers;
            project.SelectedAssignedUsers = project.Users.Select(u => u.UserId.ToString()).ToList();
            project.SelectedProjectsOwners = project.ProjectOwners.Select(u => u.UserId.ToString()).ToList();
            
            return View(project);
        }
Пример #13
0
 /// <summary>
 /// Add Project Owner
 /// Mahedee @13-02-14
 /// </summary>
 /// <param name="project"></param>
 private void AddProjectOwner(Project project)
 {
     project.ProjectOwners = new List<UserProfile>();
     if (project.SelectedProjectsOwners != null)
     {
         foreach (string userID in project.SelectedProjectsOwners)
         {
             UserProfile user = unitOfWork.UserRepository.GetUserByUserID(Convert.ToInt64(userID));
             project.ProjectOwners.Add(user);
         }
     }
 }
Пример #14
0
 private bool IsSattusExistinroject(string status,Project project)
 {
     bool isvalid = false;
     ProjectStatus projectStatus = unitOfWork.ProjectStatusRepository.FindbyProjectIDAndProjectStatusName(project.ProjectID, status);
    if (status != null)
    {
        isvalid = true;
    }
    return isvalid;
 }