public ActionResult Create(Projects_SubProject projects_subproject) { if (Authorized(RoleType.SystemManager)) { if (ModelState.IsValid) { projects_subproject.CompanyId = CurrentUser.CompanyId; projects_subproject.IsActive = true; bool wasCreated; using (SubProjectsRepository subProjectsRep = new SubProjectsRepository()) { wasCreated = subProjectsRep.Create(projects_subproject); } if (wasCreated) { return(RedirectToAction("Index")); } else { return(Error(Loc.Dic.error_sub_projects_create_error)); } } else { return(Error(ModelState)); } } 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)); } }