public ActionResult Edit(Projects_SubProject projects_subproject) { if (Authorized(RoleType.SystemManager)) { Projects_SubProject subProjectFromDB; using (SubProjectsRepository subProjectsRep = new SubProjectsRepository()) { subProjectFromDB = subProjectsRep.GetEntity(projects_subproject.Id); if (subProjectFromDB != null) { if (subProjectFromDB.CompanyId == CurrentUser.CompanyId) { subProjectFromDB.Name = projects_subproject.Name; subProjectsRep.Update(subProjectFromDB); return(RedirectToAction("Index")); } else { return(Error(Loc.Dic.error_no_permission)); } } else { return(Error(Loc.Dic.error_projects_get_error)); } } } else { return(Error(Loc.Dic.error_no_permission)); } }
public ActionResult DeleteConfirmed(int id) { if (Authorized(RoleType.SystemManager)) { Projects_SubProject subProject; using (OrdersRepository orderssRep = new OrdersRepository(CurrentUser.CompanyId)) using (SubProjectsRepository subProjectsRep = new SubProjectsRepository()) { subProject = subProjectsRep.GetEntity(id); if (subProject != null) { if (subProject.CompanyId == CurrentUser.CompanyId) { subProject.IsActive = false; Projects_SubProject update = subProjectsRep.Update(subProject); if (update != null) { return(View(subProject)); } else { return(Error(Loc.Dic.error_sub_projects_get_error)); } } else { return(Error(Loc.Dic.error_no_permission)); } } else { return(Error(Loc.Dic.error_projects_get_error)); } } } else { return(Error(Loc.Dic.error_no_permission)); } }
public ActionResult Edit(Projects_SubProject projects_subproject) { if (Authorized(RoleType.SystemManager)) { Projects_SubProject subProjectFromDB; using (SubProjectsRepository subProjectsRep = new SubProjectsRepository()) { subProjectFromDB = subProjectsRep.GetEntity(projects_subproject.Id); if (subProjectFromDB != null) { if (subProjectFromDB.CompanyId == CurrentUser.CompanyId) { subProjectFromDB.Name = projects_subproject.Name; subProjectsRep.Update(subProjectFromDB); return RedirectToAction("Index"); } else { return Error(Loc.Dic.error_no_permission); } } else { return Error(Loc.Dic.error_projects_get_error); } } } else { return Error(Loc.Dic.error_no_permission); } }
public ActionResult DeleteConfirmed(int id) { if (Authorized(RoleType.SystemManager)) { Projects_SubProject subProject; using (OrdersRepository orderssRep = new OrdersRepository(CurrentUser.CompanyId)) using (SubProjectsRepository subProjectsRep = new SubProjectsRepository()) { subProject = subProjectsRep.GetEntity(id); if (subProject != null) { if (subProject.CompanyId == CurrentUser.CompanyId) { subProject.IsActive = false; Projects_SubProject update = subProjectsRep.Update(subProject); if (update != null) return View(subProject); else return Error(Loc.Dic.error_sub_projects_get_error); } else { return Error(Loc.Dic.error_no_permission); } } else { return Error(Loc.Dic.error_projects_get_error); } } } else { return Error(Loc.Dic.error_no_permission); } }