public int EditSupplier(SupplierDetailsVM newSupplierVM, string userId) { Supplier supplier = _supplierRepository.GetSupplierById(newSupplierVM.Id); supplierMapping.MapSupplierEntityFromVM(newSupplierVM, supplier); var supplierMapped = _supplierRepository.EditSupplier(supplier, newSupplierVM.Id, userId); return(supplierMapped); }
public IActionResult EditSupplier(SupplierViewModel supplier) { if (ModelState.IsValid) { SuppliersModel new_model = new SuppliersModel(); new_model.Email = supplier.Email; new_model.Id = supplier.Id; new_model.Name = supplier.Name; new_model.PhoneNumber = supplier.PhoneNumber; //Update supplier name for the products List <ProductModel> products = _productRepository.GetProductsOfSupplier(supplier.OldName); for (int i = 0; i < products.Count; i++) { ProductModel product = new ProductModel(); product = products[i]; product.SupplierName = new_model.Name; _productRepository.Update(product); } _supplierRepository.EditSupplier(new_model); return(RedirectToAction("SuppliersDisplay")); } return(View()); }
public bool EditSupplier(NhaCungCap supplierToEdit) { if (!ValidateSupplier(supplierToEdit)) { return(false); } try { _supplierrepository.EditSupplier(supplierToEdit); } catch { return(false); } return(true); }
//https://localhost:44384/api/suppliers/supcode public IActionResult EditSupplier(string supcode, [FromBody] SupplierDTO supplierDTO) { var supplierInDb = _supplierRepo.GetSupplier(supcode); if (supplierInDb != null) { supplierDTO.Supcode = supplierInDb.Supcode; var supplier = _mapper.Map <Supplier>(supplierDTO); _supplierRepo.EditSupplier(supplier); return(Ok($"Supplier With Supply Code: {supcode} Has Been Edited Successfully!!!")); } return(NotFound($"The Supplier With Supply Code: {supcode} Was Not Found")); }
public HttpResponseMessage Put([FromBody] Models.supplier supplier) { try { if (string.IsNullOrEmpty(supplier.supplier_name)) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Supplier Name is Empty" }, formatter)); } if (string.IsNullOrEmpty(supplier.supplier_type_id.ToString())) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Supplier Type is Empty" }, formatter)); } if (string.IsNullOrEmpty(supplier.mobile)) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Mobile is Empty" }, formatter)); } if (string.IsNullOrEmpty(supplier.contact_person)) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Contact Person is Empty" }, formatter)); } if (string.IsNullOrEmpty(supplier.email)) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Email 1 is Empty" }, formatter)); } if (string.IsNullOrEmpty(supplier.receiving_company_person)) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Contact Person is Empty" }, formatter)); } if (string.IsNullOrEmpty(supplier.receiving_company_contact_email)) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Email is Empty" }, formatter)); } else { Models.supplier updateSupplier = new Models.supplier { supplier_id = supplier.supplier_id, supplier_name = supplier.supplier_name, supplier_code = supplier.supplier_code, supplier_type_id = supplier.supplier_type_id, company_address = supplier.company_address, factory_address = supplier.factory_address, phone = supplier.phone, mobile = supplier.mobile, email = supplier.email, email2 = supplier.email2, contact_person = supplier.contact_person, contact_person2 = supplier.contact_person2, total_debit = 0, total_credit = 0, balance = 0, receiving_company_name = supplier.receiving_company_name, receiving_company_person = supplier.receiving_company_person, receiving_company_contact_email = supplier.receiving_company_contact_email, vat_id = supplier.vat_id, tin_no = supplier.tin_no, updated_by = supplier.updated_by, is_active = supplier.is_active }; /* Supplier table entry by Kiron*/ supplierRepository.EditSupplier(updateSupplier); var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "success", msg = "Supplier update successfully" }, formatter)); } } catch (Exception ex) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = ex.ToString() }, formatter)); } }