public HttpResponseMessage Post([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 (supplierRepository.CheckDuplicateSupplier(supplier.supplier_name)) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Supplier Already Exists" }, 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 { supplier insertSupplier = new supplier { 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, is_active = supplier.is_active = true, created_by = supplier.created_by, vat_id = supplier.vat_id, tin_no = supplier.tin_no, receiving_company_name = supplier.receiving_company_name, receiving_company_person = supplier.receiving_company_person, receiving_company_contact_email = supplier.receiving_company_contact_email }; /* Supplier table entry by kiorn*/ supplierRepository.AddSupplier(insertSupplier); /* Supplier table entry by kiorn*/ var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "success", msg = "Supplier save successfully" }, formatter)); } } catch (Exception ex) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = ex.ToString() }, formatter)); } }