public IHttpActionResult CreateDisbursementDetails(DisbursementDetailsModel dism) { string error = ""; DisbursementDetailsModel disbm = DisbursementDetailsRepo.CreateDisbursementDetails(dism, out error); // get the inventory using the item id from Requisition details InventoryModel invm = InventoryRepo.GetInventoryByItemid(dism.Itemid, out error); // subtract the stock accoring to qty invm.Stock -= dism.Qty; // update the inventory invm = InventoryRepo.UpdateInventory(invm, out error); InventoryTransactionModel invtm = new InventoryTransactionModel { InvID = invm.Invid, ItemID = invm.Itemid, Qty = dism.Qty * -1, TransType = ConInventoryTransaction.TransType.DISBURSEMENT, TransDate = DateTime.Now, Remark = dism.Disid.ToString() }; invtm = InventoryTransactionRepo.CreateInventoryTransaction(invtm, out error); if (error != "" || disbm == null) { return(Content(HttpStatusCode.BadRequest, error)); } return(Ok(disbm)); }
public static List <DisbursementDetailsModel> UpdateDisbursementDetails(DisbursementDetailsModel dism, out string error) { error = ""; // declare and initialize new LUSSISEntities to perform update LUSSISEntities entities = new LUSSISEntities(); disbursementdetail ndism = new disbursementdetail(); try { // finding the inventory object using Inventory API model ndism = entities.disbursementdetails.Where(p => p.disid == dism.Disid && p.itemid == dism.Itemid).First <disbursementdetail>(); // transfering data from API model to DB Model ndism.disid = dism.Disid; ndism.itemid = dism.Itemid; ndism.qty = dism.Qty; // saving the update entities.SaveChanges(); // return the updated model } catch (NullReferenceException) { error = ConError.Status.NOTFOUND; } catch (Exception e) { error = e.Message; } // return the updated model return(GetDisbursementDetailsByDisbursementId(ndism.disid, out error)); }
public static DisbursementDetailsModel CreateDisbursementDetails(DisbursementDetailsModel disdm, out string error) { error = ""; LUSSISEntities entities = new LUSSISEntities(); disbursementdetail disdb = new disbursementdetail(); DisbursementDetailsModel ddm = new DisbursementDetailsModel(); try { disdb.disid = disdm.Disid; disdb.itemid = disdm.Itemid; disdb.qty = disdm.Qty; disdb = entities.disbursementdetails.Add(disdb); entities.SaveChanges(); ddm = new DisbursementDetailsModel(disdb.disid, disdb.itemid, disdb.item.description, disdb.qty, disdb.item.category.name, disdb.item.uom); } catch (NullReferenceException) { error = ConError.Status.NOTFOUND; } catch (Exception e) { error = e.Message; } return(ddm); }
public static DisbursementDetailsModel UpadateDisbursementDetails(DisbursementDetailsModel reqm, string token, out string error) { string url = APIHelper.Baseurl + "/disbursementdetails/update/"; string objectstring = JsonConvert.SerializeObject(reqm); DisbursementDetailsModel db = APIHelper.Execute <DisbursementDetailsModel>(token, objectstring, url, out error); return(db); }
public IHttpActionResult UpadateDisbursementDetails(DisbursementDetailsModel dism) { string error = ""; List <DisbursementDetailsModel> disbm = DisbursementDetailsRepo.UpdateDisbursementDetails(dism, out error); if (error != "" || disbm == null) { return(Content(HttpStatusCode.BadRequest, error)); } return(Ok(disbm)); }
private static DisbursementDetailsModel CovertDBDisbursementDetailsstoAPIDisbursementDetails(disbursementdetail disbm) { DisbursementDetailsModel dism = new DisbursementDetailsModel(disbm.disid, disbm.itemid, disbm.item.description, disbm.qty, disbm.item.category.name, disbm.item.uom); return(dism); }