public ActionResult Edit(ProjectViewModel viewModel) { if (ModelState.IsValid) { var project = db.Projects.Single(x => x.Id == viewModel.Id); if (!EntityAuthorization.ProjectEditDelete(project)) { return(HttpNotFound()); } project.InitFromViewModel(viewModel); project.ModifiedUserId = Viola.Models.User.GetCurrentUserId(); project.ModifiedDatetime = DateTime.Now.ToUniversalTime(); db.Entry(project).State = EntityState.Modified; db.SaveChanges(); ProjectTeam.Create(project.Id, Request.Form.GetValues("UserIdMulti")); ProjectTeam.AddProjectManagerToTeam(project); return(RedirectToAction("Details", "Projects", new { id = project.Id })); } ViewBag.ManagerUserId = new SelectList(Viola.Models.User.GetUsers(), "Id", "FullName", viewModel.ManagerUserId); ViewBag.UserIdMulti = new MultiSelectList(Viola.Models.User.GetUsers(), "Id", "FullName", ProjectTeam.UserIdSelection(viewModel.Id)); return(View(viewModel)); }
public ActionResult Edit(TaskViewModel viewModel) { if (ModelState.IsValid) { // kullanıcı sadece yetkisi olan projeler arasından seçim yapabilir if (!Project.GetProjectsByRole().Where(x => x.Id == viewModel.ProjectId).Any()) { return(HttpNotFound()); } var task = db.Tasks.Single(x => x.Id == viewModel.Id); if (!EntityAuthorization.TaskEdit(task)) { return(HttpNotFound()); } task.InitFromViewModel(viewModel); task.ModifiedUserId = Viola.Models.User.GetCurrentUserId(); task.ModifiedDatetime = DateTime.Now.ToUniversalTime(); db.Entry(task).State = EntityState.Modified; db.SaveChanges(); TaskAssignedUser.Create(task.Id, Request.Form.GetValues("UserIdMulti")); return(RedirectToAction("Details", "Tasks", new { id = task.Id })); } ViewBag.ProjectId = new SelectList(Project.GetProjectsByRole(), "Id", "Name", viewModel.ProjectId); ViewBag.UserIdMulti = new MultiSelectList(Viola.Models.User.GetUsersAssignedToProject(viewModel.ProjectId), "Id", "FullName", TaskAssignedUser.UserIdSelection(viewModel.Id)); return(View(viewModel)); }
public ActionResult Index(CompanyViewModel viewModel) { if (ModelState.IsValid) { var company = Company.GetCurrentCompany(db); company.InitFromViewModel(viewModel); company.ModifiedDatetime = DateTime.Now.ToUniversalTime(); db.Entry(company).State = EntityState.Modified; db.SaveChanges(); } return(View(viewModel)); }
public ActionResult Edit(EffortViewModel viewModel) { if (ModelState.IsValid) { var effort = db.Efforts.Single(x => x.Id == viewModel.Id); if (!EntityAuthorization.EffortEdit(effort)) { return(HttpNotFound()); } effort.InitFromViewModel(viewModel); effort.ModifiedUserId = Viola.Models.User.GetCurrentUserId(); effort.ModifiedDatetime = DateTime.Now.ToUniversalTime(); db.Entry(effort).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserId = new SelectList(Viola.Models.User.GetUsersForEffort(), "Id", "FullName", viewModel.UserId); ViewBag.TaskId = new SelectList(Task.GetTasksByRole(), "Id", "Name", viewModel.TaskId); return(View(viewModel)); }