Exemplo n.º 1
0
 public void UpdateTeamMate(TeamMate tm)
 {
     Database.ObjectContext.ApplyCurrentValues("TeamMates", tm);
     Database.SaveChanges();
 }
Exemplo n.º 2
0
        public ActionResult TeamMate(TeamMate tm, string action)
        {
            var ps = new ProjectService();
            if (!ps.IsUserAllowedToDo(tm.ProjectId, SessionStorage.User.Id, ProjectAction.EditTeam))
                return RedirectToAction("Index", "Home");

            if (action == "update")
            {
                ps.UpdateTeamMate(tm);
                this.SetTempMessage(Resources.Global_ChangesSaved, "success");
            }
            if (action == "remove")
            {
                ps.RemoveTeamMate(tm);
                this.SetTempMessage(Resources.Project_Team_UserRemoved, "success");
            }

            return RedirectToAction("Team", new {id = tm.ProjectId});
        }
Exemplo n.º 3
0
        public void RemoveTeamMate(TeamMate tm)
        {
            //set current tasks(assigned and executing) status of this user to created(remove assigning) and remove responsible user
            Database.Tasks.Where(
                t =>
                t.ProjectId == tm.ProjectId && t.ResponsibleId == tm.UserId &&
                (t.StatusValue == (int) TaskStatus.Assigned || t.StatusValue == (int) TaskStatus.Executing))
                .ToList().ForEach(t =>
                                      {
                                          t.Status = TaskStatus.Created;
                                          t.ResponsibleId = null;
                                      });

            Database.ObjectContext.DeleteObject(
                Database.TeamMates.FirstOrDefault(t => t.UserId == tm.UserId && t.ProjectId == tm.ProjectId));
            Database.SaveChanges();
        }