public async Task <ActionResult> PostImportedProductSource([FromBody] ImportedProductSourceVM ipsvm) { Imported_Product_Source ips = new Imported_Product_Source(); //fl.Farmer_ID = Convert.ToInt32(flvm.Farmer_ID); ips.Imported_Product_Buying_Cost = ipsvm.Imported_Product_Buying_Cost; ips.Shipment_Cost = ipsvm.Shipment_Cost; ips.Custom_Tax = ipsvm.Custom_Tax; ips.Transportation_Cost = ipsvm.Transportation_Cost; ips.Storing_Cost = ipsvm.Storing_Cost; ips.Total_Cost = ipsvm.Total_Cost; ips.Importers_WholeSale_Price = ipsvm.Importers_WholeSale_Price; db.Imported_Product_Source.Add(ips); await db.SaveChangesAsync(); return(Ok()); }
public async Task <IActionResult> PutImportedProductSource(int id, ImportedProductSourceVM ipsvm) { if (id != ipsvm.Imported_Product_Source_ID) { return(BadRequest()); } Imported_Product_Source ips = new Imported_Product_Source(); ips.Imported_Product_Source_ID = Convert.ToInt32(ipsvm.Imported_Product_Source_ID); ips.Imported_Product_Buying_Cost = ipsvm.Imported_Product_Buying_Cost; ips.Shipment_Cost = ipsvm.Shipment_Cost; ips.Custom_Tax = ipsvm.Custom_Tax; ips.Transportation_Cost = ipsvm.Transportation_Cost; ips.Storing_Cost = ipsvm.Storing_Cost; ips.Total_Cost = ipsvm.Total_Cost; ips.Importers_WholeSale_Price = ipsvm.Importers_WholeSale_Price; db.Entry(ips).State = EntityState.Modified; await db.SaveChangesAsync(); try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Imported_Product_SourceExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }