public ActionResult AssignUsers(AssignProjects model, string userId) { ProjectHelper projectHelp = new ProjectHelper(); model.user = db.Users.Where(u => u.Id == userId).FirstOrDefault(); foreach (var project in projectHelp.ListUserProjects(userId)) { Projects projectDel = db.projects.Find(project.Id); projectDel.projectUsers.Remove(model.user); db.Entry(projectDel).State = EntityState.Modified; db.SaveChanges(); } if (model.selectedProjects == null) { return(RedirectToAction("ManageUsers")); } for (int index = 0; index < model.selectedProjects.Length; index++) { var projId = model.selectedProjects[index]; model.user.Projects.Add(db.projects.Find(projId)); } db.SaveChanges(); return(RedirectToAction("ManageUsers")); }
public void assignProject() { using (var context = new CompanyDbContext()) { Console.WriteLine("Assign Projects:"); Console.Write("Enter Employee_Name:"); string name = Console.ReadLine(); var b = context.Employees.Single(t => t.EmployeeName == name); int count = context.EmployeeLeave.Count(t => t.EmployeeId == b.EmployeeId); if (count == 0) { assign.EmployeeId = b.EmployeeId; Console.Write("Enter ProjectName:"); string pname = Console.ReadLine(); var p = context.Projects.Single(t => t.ProjectName == pname); assign.ProjectId = p.ProjectId; AssignProjects.Add(assign); SaveChanges(); } else { Console.Write("Employee is on leave"); } } }
public JsonResult UpdateProjectTeam(AssignProjects projectTeam) { AssignProjectManager projectTeamManager = new AssignProjectManager(); var result = projectTeamManager.Update(projectTeam); return(Json(result, JsonRequestBehavior.AllowGet)); }
public void Delete(int Id) { AssignProjects pro = dSRContext.assignProjects.Where(o => o.Id == Id).First(); dSRContext.assignProjects.Remove(pro); dSRContext.SaveChanges(); }
public AssignProjects Update(AssignProjects projectTeam) { AssignProjects pro = dSRContext.assignProjects.Where(o => o.Id == projectTeam.Id).First(); pro.UserId = projectTeam.UserId; pro.ProjectId = projectTeam.ProjectId; pro.Description = projectTeam.Description; pro.IsActive = projectTeam.IsActive; dSRContext.SaveChanges(); return(projectTeam); }
public ActionResult AssignUsers(string userId) { var userIn = db.Users.Where(u => u.Id == userId).FirstOrDefault(); var projectsId = new List <int>(); var model = new AssignProjects { user = userIn, projects = new MultiSelectList(db.projects, "Id", "name", projectsId) }; return(View(model)); }
public bool SaveAssignedProjects(AssignProjects assignProjectsModel) { bool result = false; using (var _context = new DatabaseContext()) { try { if (assignProjectsModel.Projects != null) { for (int i = 0; i < assignProjectsModel.Projects.Count(); i++) { var AssignedProjects = new AssignedProjects { ManagerId = assignProjectsModel.ManagerId, Status = "A", ProjectId = assignProjectsModel.Projects[i].ProjectID }; _context.AssignedProjects.Add(AssignedProjects); _context.SaveChanges(); } } else if (assignProjectsModel.Users != null) { for (int i = 0; i < assignProjectsModel.Users.Count(); i++) { var AssignedProjects = new AssignedProjects { ManagerId = assignProjectsModel.Users[i].RegistrationID, Status = "A", ProjectId = assignProjectsModel.ProjectId }; _context.AssignedProjects.Add(AssignedProjects); _context.SaveChanges(); } } result = true; } catch (Exception) { throw; } return(result); } }
public void LoadProjects(AssignProjects callback) { callback(base.LoadProjects()); }
void LoadProjectsAsync_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { AssignProjects callback = (AssignProjects)((object[])e.Result)[1]; IEnumerable<Project> results = (IEnumerable<Project>)((object[])e.Result)[0]; callback(results); }
public void LoadProjects(AssignProjects callback) { BackgroundWorker loadProjectsAsync = new BackgroundWorker(); loadProjectsAsync.DoWork += new DoWorkEventHandler(LoadProjectsAsync_DoWork); loadProjectsAsync.RunWorkerCompleted += new RunWorkerCompletedEventHandler(LoadProjectsAsync_RunWorkerCompleted); loadProjectsAsync.RunWorkerAsync(callback); }
public AssignProjects Add(AssignProjects projectTeam) { dSRContext.assignProjects.Add(projectTeam); dSRContext.SaveChanges(); return(projectTeam); }
public IHttpActionResult SaveAssignedProjects(AssignProjects assignProjectsModel) { var result = _IProjectRepository.SaveAssignedProjects(assignProjectsModel); return(Ok(result)); }