//add adjustment, single entry, to an voucher public ActionResult SubmitAdjustmentEntry(int adjusQty, string VoucherReason, string SelectedVoucher, int ItemId) { // create new voucher detail object AdjustmentDetail adjustmentDetail = new AdjustmentDetail() { ItemCatalogueId = ItemId, Reason = VoucherReason, Quantity = adjusQty }; //Update adjustmentVoucher with new dsetail int VoucherId = Int32.Parse(SelectedVoucher); using (var db = new ADProjectDb()) { //Check if entry existed bool IsExisted = inventoryService.CheckifAdjExist(db, ItemId, VoucherId); if (IsExisted == true) { inventoryService.UpdateAdjDetails(db, ItemId, VoucherId, adjusQty, VoucherReason); } else { inventoryService.AddtoAdjustmentVoucher(db, VoucherId, adjustmentDetail); } } // redirect back to inventory list return(RedirectToAction("showLowStock", "Inventory")); }
// [System.Web.Http.AcceptVerbs("PUT")] // [System.Web.Http.Route("api/inventory/put")] // [System.Web.Http.HttpPut] public IHttpActionResult PutAdjustmentVoucherUpdate(int adjusQty, string VoucherReason, int VoucherId, int ItemId) { // create new voucher detail object AdjustmentDetail adjustmentDetail = new AdjustmentDetail() { ItemCatalogueId = ItemId, Reason = VoucherReason, Quantity = adjusQty }; //Update adjustmentVoucher with new dsetail using (var db = new ADProjectDb()) { //Check if entry existed bool IsExisted = inventoryService.CheckifAdjExist(db, ItemId, VoucherId); if (IsExisted == true) { inventoryService.UpdateAdjDetails(db, ItemId, VoucherId, adjusQty, VoucherReason); } else { inventoryService.AddtoAdjustmentVoucher(db, VoucherId, adjustmentDetail); } } return(Ok()); }