Ejemplo n.º 1
0
 public async Task <IHttpActionResult> UpdateRequestStatus(BalanceRequestViewModel model)
 {
     if (model.Status == (int)BalanceRequestFlag.Approved)
     {
         return(Ok(await ApproveBalance(model)));
     }
     else
     {
         return(Ok(await DenyBalance(model)));
     }
 }
Ejemplo n.º 2
0
 private async Task <ObjectDto <BalanceRequestViewModel> > ApproveBalance(BalanceRequestViewModel model)
 {
     if (model.Purpose == (int)BalanceRequestPurpose.For_All_Services)
     {
         return(await ApproveBalanceforAllServices(model));
     }
     else if (model.Purpose == (int)BalanceRequestPurpose.From_Rail_To_Agent_Account)
     {
         return(await ApproveBalanceFromRailToAccount(model));
     }
     else
     {
         return(await ApproveBalanceFromAccountToRail(model));
     }
 }
 public PBalanceRequestDto(BalanceRequestViewModel model)
 {
     Id               = model.Id;
     CreatedDate      = model.CreatedDate;
     LastModifiedDate = model.LastModifiedDate;
     Amount           = model.Amount;
     AmountApproved   = model.AmountApproved;
     Mode             = model.Mode;
     PBankId          = model.PBankId;
     TransactionId    = model.TransactionId;
     Status           = model.Status;
     DepositDate      = model.DepositDate;
     DepositorsACNo   = model.DepositorsACNo;
     DepositorsBank   = model.DepositorsBank;
     DepositorsName   = model.DepositorsName;
     UserId           = model.UserId;
     Remarks          = model.Remarks;
     Purpose          = model.Purpose;
 }
Ejemplo n.º 4
0
        private async Task <ObjectDto <BalanceRequestViewModel> > DenyBalance(BalanceRequestViewModel model)
        {
            var messages = new Messages();
            ObjectDto <BalanceRequestViewModel> result = new ObjectDto <BalanceRequestViewModel>();

            try
            {
                using (var db = new ApplicationDbContext())
                {
                    var userId   = User.Identity.GetUserId();
                    var childObj = await db.PUserProfile.FindAsync(model.UserId);

                    model.LastModifiedDate = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));
                    db.Entry(new PBalanceRequestDto(model)).State = EntityState.Modified;
                    if ((await db.SaveChangesAsync()) > 0)
                    {
                        result.Object    = model;
                        result.valid     = true;
                        messages.Message = "You have rejected balance request for " + childObj.Agency;
                        messages.Type    = Toaster.SUCCESS.ToString();
                        result.messages.Add(messages);
                    }
                    else
                    {
                        messages.Message = "Internal Server Error";
                        result.messages.Add(messages);
                    }
                }
            }
            catch (Exception e)
            {
                messages.Message = e.Message;
                result.messages.Add(messages);
            }
            return(result);
        }
Ejemplo n.º 5
0
        private async Task <ObjectDto <BalanceRequestViewModel> > ApproveBalanceFromAccountToRail(BalanceRequestViewModel model)
        {
            var messages = new Messages();
            ObjectDto <BalanceRequestViewModel> result = new ObjectDto <BalanceRequestViewModel>();

            try
            {
                using (var db = new ApplicationDbContext())
                {
                    var userId  = User.Identity.GetUserId();
                    var userObj = await db.PUserProfile.FindAsync(userId);

                    var childObj = await db.PUserProfile.FindAsync(model.UserId);

                    if (childObj.Balance >= model.AmountApproved)
                    {
                        userObj.Balance          += model.AmountApproved;
                        childObj.Balance         -= model.AmountApproved;
                        model.LastModifiedDate    = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));
                        childObj.LastModifiedDate = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));
                        userObj.LastModifiedDate  = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));
                        db.Entry(new PBalanceRequestDto(model)).State = EntityState.Modified;
                        db.Entry(userObj).State  = EntityState.Modified;
                        db.Entry(childObj).State = EntityState.Modified;

                        var childPassBook = new PassBookDto
                        {
                            Amount           = model.AmountApproved,
                            Balance          = childObj.Balance,
                            Credit           = 0,
                            Debit            = model.AmountApproved,
                            ServiceId        = 0,
                            Status           = (int)StatusFlag.Success,
                            TransactionId    = model.Id,
                            UserId           = childObj.UserId,
                            Remarks          = "Rail Balance Approved",
                            LastModifiedDate = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("India Standard Time")),
                            CreatedDate      = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"))
                        };
                        var userPassBook = new PassBookDto
                        {
                            Amount           = model.AmountApproved,
                            Balance          = userObj.Balance,
                            Credit           = model.AmountApproved,
                            Debit            = 0,
                            Status           = (int)StatusFlag.Success,
                            TransactionId    = model.Id,
                            UserId           = userObj.UserId,
                            Remarks          = "Rail Balance Approved",
                            ServiceId        = 0,
                            LastModifiedDate = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("India Standard Time")),
                            CreatedDate      = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"))
                        };

                        db.PassBook.Add(userPassBook);
                        db.PassBook.Add(childPassBook);
                        if ((await db.SaveChangesAsync()) > 0)
                        {
                            result.Object    = model;
                            result.valid     = true;
                            messages.Message = "You have approved rail balance request for " + childObj.Agency;
                            messages.Type    = Toaster.SUCCESS.ToString();
                            result.messages.Add(messages);
                        }
                        else
                        {
                            messages.Message = "Internal Server Error";
                            result.messages.Add(messages);
                        }
                    }
                    else
                    {
                        messages.Message = "Not enough balance is available in agent's account";
                        result.messages.Add(messages);
                    }
                }
            }
            catch (Exception e)
            {
                messages.Message = e.Message;
                result.messages.Add(messages);
            }
            return(result);
        }