//[Authorize] // POST: api/PurchaseOrder public void Post([FromBody] PurchaseOrder purchaseOrder) { _PurchaseOrderRepository.AddPurchaseOrder(purchaseOrder); }
public HttpResponseMessage Post([FromBody] PurchaseOrderModel purchaseOrderModel) { try { int counter = 0; var details = purchaseOrderModel.PoDetailsList; foreach (var item in details) { var poDetails = new purchase_order_details { product_id = item.product_id, color_id = item.color_id, product_version_id = item.product_version_id, product_category_id = item.product_category_id }; var kkk = productCategoryRepository.GetProductCategoryByProductId((long)item.product_id); if (kkk != 3 && item.color_id == null && item.product_version_id == null) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "warning", msg = "Please Select color and version !!" }, formatter)); } counter++; } if (string.IsNullOrEmpty(purchaseOrderModel.PoMasterData.supplier_id.ToString())) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "warning", msg = "Please Select Supplier !!" }, formatter)); } if (string.IsNullOrEmpty(purchaseOrderModel.PoMasterData.company_id.ToString())) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "warning", msg = "Please Select Company !!" }, formatter)); } if (string.IsNullOrEmpty(purchaseOrderModel.PoMasterData.currency_id.ToString())) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "warning", msg = "Please Select Currency !!" }, formatter)); } if (counter == 0) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "warning", msg = "Please give the product details Information !!" }, formatter)); } else { purchaseOrderRepository.AddPurchaseOrder(purchaseOrderModel); var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "success", msg = "Purchase Order save successfully" }, formatter)); } } catch (Exception ex) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "warning", msg = ex.ToString() }, formatter)); } }