public ActionResult Edit(Supplier supplier) { if (!Authorized(RoleType.SystemManager)) { return(Error(Loc.Dic.error_no_permission)); } if (ModelState.IsValid) { Supplier supplierFromDB; bool wasUpdated; using (SuppliersRepository supplierRep = new SuppliersRepository(CurrentUser.CompanyId)) { supplierFromDB = supplierRep.GetEntity(supplier.Id); if (supplierFromDB == null) { return(Error(Loc.Dic.error_supplier_not_found)); } if (supplierFromDB.CompanyId != CurrentUser.CompanyId) { return(Error(Loc.Dic.error_no_permission)); } supplierFromDB.Name = supplier.Name; supplierFromDB.ExternalId = supplier.ExternalId; supplierFromDB.Activity_Hours = supplier.Activity_Hours; supplierFromDB.Additional_Phone = supplier.Additional_Phone; supplierFromDB.Address = supplier.Address; supplierFromDB.Branch_line = supplier.Branch_line; supplierFromDB.Crew_Number = supplier.Crew_Number; supplierFromDB.Customer_Number = supplier.Customer_Number; supplierFromDB.EMail = supplier.EMail; supplierFromDB.Fax = supplier.Fax; supplierFromDB.Notes = supplier.Notes; supplierFromDB.Phone_Number = supplier.Phone_Number; supplierFromDB.Presentor_name = supplier.Presentor_name; supplierFromDB.VAT_Number = supplier.VAT_Number; if (supplierRep.Update(supplierFromDB) != null) { return(RedirectToAction("Index")); } else { return(Error(Loc.Dic.error_database_error)); } } } else { return(Error(ModelState)); } }
public ActionResult Details(int id = 0) { Supplier supplier; using (SuppliersRepository supplierssRep = new SuppliersRepository(CurrentUser.CompanyId)) { supplier = supplierssRep.GetEntity(id); } if (supplier == null) { return(Error(Loc.Dic.error_supplier_not_found)); } return(View(supplier)); }
public ActionResult Edit(Supplier supplier) { if (!Authorized(RoleType.SystemManager)) return Error(Loc.Dic.error_no_permission); if (ModelState.IsValid) { Supplier supplierFromDB; bool wasUpdated; using (SuppliersRepository supplierRep = new SuppliersRepository(CurrentUser.CompanyId)) { supplierFromDB = supplierRep.GetEntity(supplier.Id); if (supplierFromDB == null) return Error(Loc.Dic.error_supplier_not_found); if (supplierFromDB.CompanyId != CurrentUser.CompanyId) return Error(Loc.Dic.error_no_permission); supplierFromDB.Name = supplier.Name; supplierFromDB.ExternalId = supplier.ExternalId; supplierFromDB.Activity_Hours = supplier.Activity_Hours; supplierFromDB.Additional_Phone = supplier.Additional_Phone; supplierFromDB.Address = supplier.Address; supplierFromDB.Branch_line = supplier.Branch_line; supplierFromDB.Crew_Number = supplier.Crew_Number; supplierFromDB.Customer_Number = supplier.Customer_Number; supplierFromDB.EMail = supplier.EMail; supplierFromDB.Fax = supplier.Fax; supplierFromDB.Notes = supplier.Notes; supplierFromDB.Phone_Number = supplier.Phone_Number; supplierFromDB.Presentor_name = supplier.Presentor_name; supplierFromDB.VAT_Number = supplier.VAT_Number; if (supplierRep.Update(supplierFromDB) != null) return RedirectToAction("Index"); else return Error(Loc.Dic.error_database_error); } } else { return Error(ModelState); } }
public ActionResult Details(int id = 0) { Supplier supplier; using (SuppliersRepository supplierssRep = new SuppliersRepository(CurrentUser.CompanyId)) { supplier = supplierssRep.GetEntity(id); } if (supplier == null) return Error(Loc.Dic.error_supplier_not_found); return View(supplier); }