public static DisbursementLockerModel UpdateDisbursementLocker(DisbursementLockerModel lislm, out string error) { error = ""; // entites used only by Get Methods LUSSISEntities entities = new LUSSISEntities(); disbursementlocker disl = new disbursementlocker(); DisbursementLockerModel dislm = new DisbursementLockerModel(); try { disl = entities.disbursementlockers.Where(p => p.reqid == lislm.ReqID && p.lockerid == lislm.LockerID).FirstOrDefault(); disl.collecteddate = DateTime.Now; disl.status = lislm.Status; entities.SaveChanges(); dislm = GetDisbursementLockerByReqIDAndLockerID(disl.reqid, disl.lockerid, out error); } // if locker not found, will throw NOTFOUND exception catch (NullReferenceException) { // if there is NULL Exception error, error will be 404 error = ConError.Status.NOTFOUND; } catch (Exception e) { // for other exceptions error = e.Message; } //retuning the lockercollectionpoint object return(dislm); }
public static DisbursementLockerModel GetDisbursementLockerByReqIDAndLockerID(int ReqID, int LockerID, out string error) { error = ""; LUSSISEntities entities = new LUSSISEntities(); disbursementlocker disl = new disbursementlocker(); DisbursementLockerModel dislm = new DisbursementLockerModel(); try { disl = entities.disbursementlockers.Where(p => p.reqid == ReqID && p.lockerid == LockerID).FirstOrDefault(); dislm = CovertDisLockertoModel(disl); } catch (NullReferenceException) { // if there is NULL Exception error, error will be 404 error = ConError.Status.NOTFOUND; } catch (Exception e) { // for other exceptions error = e.Message; } return(dislm); }
public static DisbursementLockerModel CreateDisbursementLocker(DisbursementLockerModel lislm, out string error) { error = ""; // entites used only by Get Methods LUSSISEntities entities = new LUSSISEntities(); disbursementlocker disl = new disbursementlocker(); DisbursementLockerModel dislm = new DisbursementLockerModel(); try { disl.disid = lislm.DisID; disl.reqid = lislm.ReqID; disl.lockerid = lislm.LockerID; disl.deptid = lislm.DeptID; disl.delivereddate = DateTime.Now.AddDays(2); disl.collecteddate = DateTime.Now.AddDays(9); disl.status = 1; entities.disbursementlockers.Add(disl); entities.SaveChanges(); LockerCollectionPointModel lcpm = GetLockerCPByLockerid(disl.lockerid, out error); lcpm.Status = ConLockerCollectionPoint.Active.NOTAVAILABLE; lcpm = UpdateLockerCP(lcpm, out error); dislm = GetDisbursementLockerByReqIDAndLockerID(disl.reqid, disl.lockerid, out error); } // if locker not found, will throw NOTFOUND exception catch (NullReferenceException) { // if there is NULL Exception error, error will be 404 error = ConError.Status.NOTFOUND; } catch (Exception e) { // for other exceptions error = e.Message; } //retuning the lockercollectionpoint object return(dislm); }
private static DisbursementLockerModel CovertDisLockertoModel(disbursementlocker disl) { DisbursementLockerModel dislm = new DisbursementLockerModel(disl.disid, disl.reqid, disl.lockerid, disl.delivereddate, disl.collecteddate, disl.status, disl.requisition.deptid); return(dislm); }