Exemplo n.º 1
0
        public async Task <bool> UpdatePawnshopTransactions(tbl_ipos_pawnshop_transactions model)
        {
            try
            {
                using (var uow = _unitOfWorkFactory.Create())
                {
                    var result = await FindByIdPawnshopTransactions(model.TransactionId);

                    if (result != null)
                    {
                        uow.PawnshopTransactionsRepository.Update(model);
                        await uow.SaveChangesAsync();

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 2
0
        public async Task <JsonResult> SaveApproval(ApproveTransactionModel model)
        {
            try
            {
                bool   success = false;
                string message = "";


                if (string.IsNullOrEmpty(model.TransactionId.ToString()) || model.TransactionId.ToString() == "0")
                {
                    message = "Error saving data. no transaction";
                }
                else
                {
                    tbl_ipos_pawnshop_transactions model1 = await _pawnshopTransactionService.FindByTransactionNo(model.TransactionNo);

                    model1.Status     = "For approval";
                    model1.ReviewedBy = "";
                    model1.ApprovedBy = "";

                    var result = await _pawnshopTransactionService.UpdatePawnshopTransactions(model1);

                    if (result)
                    {
                        message = "Successful!";
                    }
                    else
                    {
                        message = "Error saving data. no transaction";
                    }
                }

                return(Json(new { success = success, message = message }));
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 3
0
        public async Task <JsonResult> SaveAppraisedItem(tbl_ipos_appraiseditem item)
        {
            try
            {
                tbl_ipos_appraiseditem model = null;

                bool   success = false;
                string message = "";

                if (string.IsNullOrEmpty(item.AppraiseId.ToString()) || item.AppraiseId.ToString() == "0")
                {
                    //DateTime dt = DateTime.ParseExact(item.AppraiseDate, "yyyy/MM/dd", CultureInfo.InvariantCulture);

                    model = new tbl_ipos_appraiseditem();
                    model.AppraiseDate      = item.AppraiseDate;
                    model.AppraiseNo        = item.AppraiseNo;
                    model.ItemTypeId        = item.ItemTypeId;
                    model.ItemCategoryId    = item.ItemCategoryId;
                    model.ItemName          = item.ItemName;
                    model.Brand             = item.Brand;
                    model.Karat             = item.Karat;
                    model.Weight            = item.Weight;
                    model.AppraisedValue    = item.AppraisedValue;
                    model.Remarks           = item.Remarks;
                    model.CustomerFirstName = item.CustomerFirstName;
                    model.CustomerLastName  = item.CustomerLastName;
                    model.IsPawned          = false;
                    model.CreatedAt         = DateTime.Now;
                    model.CreatedBy         = "";

                    var result = await _appraisalService.Save(model);

                    success = result;
                    if (result)
                    {
                        tbl_ipos_pawnshop_transactions model1 = await _pawnshopTransactionService.FindByIdPawnshopTransactions(item.AppraiseId);

                        model1.Status = "For pawning";
                        await _pawnshopTransactionService.UpdatePawnshopTransactions(model1);

                        message = "Successfully saved.";
                    }
                    else
                    {
                        message = "Error saving data. Duplicate entry.";
                    }
                }
                else
                {
                    model = await _appraisalService.FindById(item.AppraiseId);

                    model.ItemTypeId        = item.ItemTypeId;
                    model.ItemCategoryId    = item.ItemCategoryId;
                    model.ItemName          = item.ItemName;
                    model.Brand             = item.Brand;
                    model.Karat             = item.Karat;
                    model.Weight            = item.Weight;
                    model.AppraisedValue    = item.AppraisedValue;
                    model.Remarks           = item.Remarks;
                    model.CustomerFirstName = item.CustomerFirstName;
                    model.CustomerLastName  = item.CustomerLastName;
                    model.IsPawned          = false;
                    model.CreatedAt         = DateTime.Now;
                    model.CreatedBy         = "";

                    var result = await _appraisalService.Update(model);

                    success = result;
                    if (result)
                    {
                        tbl_ipos_pawnshop_transactions model1 = await _pawnshopTransactionService.FindByIdPawnshopTransactions(item.AppraiseId);

                        model1.Status = "For pawning";
                        await _pawnshopTransactionService.UpdatePawnshopTransactions(model1);

                        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);
            }
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        public async Task <JsonResult> SavePawning(tbl_ipos_pawneditem model)
        {
            try
            {
                bool   success = false;
                string message = "";

                if (string.IsNullOrEmpty(model.PawnedItemId.ToString()) || model.PawnedItemId.ToString() == "0")
                {
                    tbl_ipos_pawneditem model1 = new tbl_ipos_pawneditem();
                    model1.PawnedItemNo         = model.PawnedItemNo;
                    model1.PawnedDate           = model.PawnedDate;
                    model1.TransactionNo        = model.TransactionNo;
                    model1.PawnedItemContractNo = model.PawnedItemContractNo;
                    model1.LoanableAmount       = model.LoanableAmount;
                    model1.InterestRate         = model.InterestRate;
                    model1.InterestAmount       = model.InterestAmount;
                    model1.InitialPayment       = model.InitialPayment;
                    model1.ServiceCharge        = model.ServiceCharge;
                    model1.Others             = model.Others;
                    model1.IsInterestDeducted = model.IsInterestDeducted;
                    model1.NetCashOut         = model.NetCashOut;
                    model1.TermsId            = model.TermsId;
                    model1.ScheduleOfPayment  = model.ScheduleOfPayment;
                    model1.NoOfPayments       = model.NoOfPayments;
                    model1.DueDateStart       = model.DueDateStart;
                    model1.DueDateEnd         = model.DueDateEnd;
                    model1.Status             = "";
                    model1.IsReleased         = false;
                    model1.CreatedBy          = "";
                    model1.CreatedAt          = DateTime.Now;

                    var result = await _pawningService.Save(model1);

                    success = result;

                    if (result)
                    {
                        tbl_ipos_pawnshop_transactions model2 = await _pawnshopTransactionService.FindByTransactionNo(model.TransactionNo);

                        model2.Status = "For approval";
                        await _pawnshopTransactionService.UpdatePawnshopTransactions(model2);

                        message = "Successfully saved.";
                    }
                    else
                    {
                        message = "Error saving data. Duplicate entry.";
                    }
                }
                else
                {
                    tbl_ipos_pawneditem model1 = new tbl_ipos_pawneditem();
                    model1 = await _pawningService.FindById(model.PawnedItemId);

                    model1.PawnedDate           = model.PawnedDate;
                    model1.TransactionNo        = model.TransactionNo;
                    model1.PawnedItemContractNo = model.PawnedItemContractNo;
                    model1.LoanableAmount       = model.LoanableAmount;
                    model1.InterestRate         = model.InterestRate;
                    model1.InterestAmount       = model.InterestAmount;
                    model1.InitialPayment       = model.InitialPayment;
                    model1.ServiceCharge        = model.ServiceCharge;
                    model1.Others             = model.Others;
                    model1.IsInterestDeducted = model.IsInterestDeducted;
                    model1.NetCashOut         = model.NetCashOut;
                    model1.TermsId            = model.TermsId;
                    model1.ScheduleOfPayment  = model.ScheduleOfPayment;
                    model1.NoOfPayments       = model.NoOfPayments;
                    model1.DueDateStart       = model.DueDateStart;
                    model1.DueDateEnd         = model.DueDateEnd;

                    var result = await _pawningService.Update(model1);

                    success = result;
                    if (result)
                    {
                        tbl_ipos_pawnshop_transactions model2 = await _pawnshopTransactionService.FindByTransactionNo(model.TransactionNo);

                        model2.Status = "For approval";
                        await _pawnshopTransactionService.UpdatePawnshopTransactions(model2);

                        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);
            }
        }
Exemplo n.º 6
0
        public async Task <JsonResult> SaveAppraisal(tbl_ipos_appraiseditem model)
        {
            try
            {
                bool   success = false;
                string message = "";

                if (string.IsNullOrEmpty(model.AppraiseId.ToString()) || model.AppraiseId.ToString() == "0")
                {
                    tbl_ipos_appraiseditem model1 = new tbl_ipos_appraiseditem();
                    model1.AppraiseDate = model.AppraiseDate;
                    //model1.AppraiseNo = "";
                    //model1.ItemTypeId = model.ItemTypeId;
                    //model1.ItemCategoryId = model.ItemCategoryId;
                    //model1.ItemName = model.ItemName;
                    model1.ItemFeature    = model.ItemFeature;
                    model1.SerialNo       = model.SerialNo;
                    model1.ItemCondition  = model.ItemCondition;
                    model1.Weight         = model.Weight;
                    model1.AppraisedValue = model.AppraisedValue;
                    //model1.Remarks = model.Remarks;
                    //model1.CustomerFirstName = model.first_name;
                    //model1.CustomerLastName = model.last_name;
                    //model1.IsPawned = false;
                    //model1.CreatedAt = DateTime.Now;
                    //model1.CreatedBy = "";
                    //model1.PawnshopTransactionId = model.TransactionNo.ToString();

                    var result = await _appraisalService.Save(model1);

                    success = result;

                    if (result)
                    {
                        message = "Successfully saved.";
                    }
                    else
                    {
                        message = "Error saving data. Duplicate entry.";
                    }
                }
                else
                {
                    tbl_ipos_appraiseditem model1 = new tbl_ipos_appraiseditem();
                    model1 = await _appraisalService.FindByTransactionNo(model.PawnshopTransactionId);

                    model1.AppraiseDate = model.AppraiseDate;
                    //model1.AppraiseNo = "";
                    //model1.ItemTypeId = model.ItemTypeId;
                    //model1.ItemCategoryId = model.ItemCategoryId;
                    //model1.ItemName = model.ItemName;
                    model1.ItemFeature    = model.ItemFeature;
                    model1.SerialNo       = model.SerialNo;
                    model1.ItemCondition  = model.ItemCondition;
                    model1.Karat          = model.Karat;
                    model1.Weight         = model.Weight;
                    model1.AppraisedValue = model.AppraisedValue;
                    //model1.Remarks = model.Remarks;
                    //model1.CustomerFirstName = model.first_name;
                    //model1.CustomerLastName = model.last_name;
                    //model1.IsPawned = false;
                    //model1.CreatedAt = DateTime.Now;
                    //model1.CreatedBy = "";
                    //model1.PawnshopTransactionId = model.TransactionNo.ToString();
                    var result = await _appraisalService.Update(model1);

                    success = result;
                    if (result)
                    {
                        tbl_ipos_pawnshop_transactions model2 = await _pawnshopTransactionService.FindByTransactionNo(model.PawnshopTransactionId);

                        model2.Status = "For pawning";
                        await _pawnshopTransactionService.UpdatePawnshopTransactions(model2);

                        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);
            }
        }
Exemplo n.º 7
0
        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);
            }
        }