public async Task <bool> UpdateNoGenerator(tbl_ipos_no_generator model) { try { using (var uow = _unitOfWorkFactory.Create()) { var result = await FindByIdAndTerminalNoGenerator(model.NoId, model.Terminal); if (result != null) { uow.NoGeneratorRepository.Update(model); await uow.SaveChangesAsync(); return(true); } else { return(false); } } } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task <JsonResult> SaveNoGenerator(tbl_ipos_no_generator noGenerator) { try { tbl_ipos_no_generator noGeneratorModel = null; bool success = false; string message = ""; if (string.IsNullOrEmpty(noGenerator.NoId.ToString()) || noGenerator.NoId.ToString() == "0") { noGeneratorModel = new tbl_ipos_no_generator(); noGeneratorModel.NoId = noGenerator.NoId; noGeneratorModel.NoDescription = noGenerator.NoDescription; noGeneratorModel.No = noGenerator.No; var result = await _referenceService.SaveNoGenerator(noGeneratorModel); success = result; if (result) { message = "Successfully saved."; } else { message = "Error saving data. Please contact administrator."; } } else { noGeneratorModel = await _referenceService.FindByIdNoGenerator(noGeneratorModel.NoId); noGeneratorModel.NoId = noGenerator.NoId; noGeneratorModel.NoDescription = noGenerator.NoDescription; noGeneratorModel.No = noGenerator.No; var result = await _referenceService.UpdateNoGenerator(noGeneratorModel); success = result; if (result) { message = "Successfully updated."; } else { message = "Error saving data. Please contact administrator."; } } return(Json(new { success = success, message = message })); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task <JsonResult> SaveTransactionPawning(PawnshopTransactionModel model) { try { bool success = false; string message = ""; if (string.IsNullOrEmpty(model.TransactionId.ToString()) || model.TransactionId.ToString() == "0") { tbl_ipos_pawnshop_transactions model1 = new tbl_ipos_pawnshop_transactions(); model1.TransactionNo = model.TransactionNo; model1.TransactionDate = model.TransactionDate; model1.TransactionType = "Pawning"; model1.CustomerId = model.CustomerId; model1.Terminal = "1"; model1.Status = "On Process"; model1.ReviewedBy = ""; model1.ApprovedBy = ""; model1.CreatedBy = ""; model1.CreatedAt = DateTime.Now; tbl_ipos_appraiseditem model2 = new tbl_ipos_appraiseditem(); model2.AppraiseDate = DateTime.Now; model2.AppraiseNo = ""; model2.ItemTypeId = model.ItemTypeId; model2.ItemCategoryId = model.ItemCategoryId; model2.ItemName = model.ItemName; model2.Weight = ""; model2.AppraisedValue = 0; model2.Remarks = model.Remarks; model2.CustomerFirstName = model.first_name; model2.CustomerLastName = model.last_name; model2.IsPawned = false; model2.CreatedAt = DateTime.Now; model2.CreatedBy = ""; model2.PawnshopTransactionId = model.TransactionNo; tbl_ipos_pawneditem model3 = new tbl_ipos_pawneditem(); model3.PawnedItemNo = ""; model3.PawnedDate = null; model3.PawnedDate = ""; model3.CustomerId = ""; model3.PawnedItemContractNo = ""; model3.LoanableAmount = ""; model3.InterestRate = ""; model3.InterestAmount = ""; model3.InitialPayment = ""; model3.ServiceCharge = ""; model3.Others = ""; model3.IsInterestDeducted = ""; model3.NetCashOut = ""; model3.TermsId = ""; model3.ScheduleOfPayment = ""; model3.NoOfPayments = ""; model3.DueDateStart = ""; model3.DueDateEnd = ""; model3.Status = ""; model3.IsReleased = ""; model3.CreatedBy = ""; model3.CreatedAt = ""; var result = await _pawnshopTransactionService.SavePawnshopTransactions(model1); var result1 = await _appraisalService.Save(model2); success = result; success = result1; if (result) { tbl_ipos_no_generator noGenerator = new tbl_ipos_no_generator(); noGenerator = await _referenceService.FindByIdAndTerminalNoGenerator(1, "1"); noGenerator.No = Int32.Parse(model.TransactionNo) + 1; await _referenceService.UpdateNoGenerator(noGenerator); message = "Successfully saved."; } else { message = "Error saving data. Duplicate entry."; } } return(Json(new { success = success, message = message })); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task <JsonResult> SaveTransactionPawning(TransactionsModel model) { try { bool success = false; string message = ""; if (string.IsNullOrEmpty(model.TransactionId.ToString()) || model.TransactionId.ToString() == "0") { tbl_ipos_pawnshop_transactions model1 = new tbl_ipos_pawnshop_transactions(); model1.TransactionNo = model.TransactionNo; model1.TransactionDate = model.TransactionDate; model1.TransactionType = "Pawning"; model1.CustomerId = model.CustomerId; model1.Terminal = "1"; model1.Status = "For appraisal"; model1.ReviewedBy = ""; model1.ApprovedBy = ""; model1.CreatedBy = ""; model1.CreatedAt = DateTime.Now; tbl_ipos_appraiseditem model2 = new tbl_ipos_appraiseditem(); model2.AppraiseDate = DateTime.Now; model2.AppraiseNo = ""; model2.ItemTypeId = model.ItemTypeId; model2.ItemCategoryId = model.ItemCategoryId; model2.ItemName = model.ItemName; model2.ItemFeature = ""; model2.SerialNo = ""; model2.ItemCondition = ""; model2.Weight = ""; model2.AppraisedValue = 0; model2.Remarks = model.Remarks; model2.CustomerFirstName = model.first_name; model2.CustomerLastName = model.last_name; model2.IsPawned = false; model2.CreatedAt = DateTime.Now; model2.CreatedBy = ""; model2.PawnshopTransactionId = model.TransactionNo.ToString(); var result = await _pawnshopTransactionService.SavePawnshopTransactions(model1); var result1 = await _appraisalService.Save(model2); success = result; success = result1; if (result) { tbl_ipos_no_generator noGenerator = new tbl_ipos_no_generator(); noGenerator = await _referenceService.FindByIdAndTerminalNoGenerator(1, "1"); noGenerator.No = Int32.Parse(model.TransactionNo) + 1; await _referenceService.UpdateNoGenerator(noGenerator); message = "Successfully saved."; } else { message = "Error saving data. Duplicate entry."; } } return(Json(new { success = success, message = message })); } catch (Exception ex) { throw new Exception(ex.Message); } }