public ActionResult Pay(int Id, CreditViewModel credit)
        {
            Project project = db.ProjectSet.FirstOrDefault(q => q.Id == Id);

            if (ModelState.IsValid)
            {
                ProjectAccess access = new ProjectAccess();
                access.UserId    = UserHelper.Current().Id;
                access.ProjectId = project.Id;

                Payment payment = new Payment();
                payment.Amount        = project.Price;
                payment.Date          = DateTime.Now;
                payment.UserId        = UserHelper.Current().Id;
                payment.ProjectAccess = access;
                db.PaymentSet.Add(payment);

                db.SaveChanges();

                return(RedirectToAction("Success"));
            }

            ViewBag.project = project;

            return(View("Index"));
        }
Example #2
0
        public ActionResult Create(CreditViewModel insertCredit)
        {
            if (Session["personelId"] == null || Session["yetkiId"] == null)
            {
                return(RedirectToActionPermanent("Index", "Login"));
            }
            HttpClient hc = new HttpClient();

            hc.BaseAddress = new Uri("https://localhost:44300/api/ListsCredit/");

            // bekleyen
            insertCredit.Credit.status = "W";

            //insertCredit metodu çağrılıyor ve veritabanında create işlemi gerçekleştiriliyor.
            var insertRecord = hc.PostAsJsonAsync <credit>("ListsCredit", insertCredit.Credit);

            insertRecord.Wait();

            var saveData = insertRecord.Result;

            if (saveData.IsSuccessStatusCode)
            {
                return(RedirectToAction("Index"));
            }
            return(View(insertCredit));
        }
Example #3
0
        public async Task <IActionResult> Deposito(CreditViewModel deposito)
        {
            var token = await HttpContext.GetTokenAsync("access_token");

            var client = new HttpClient();

            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

            var json = JsonConvert.SerializeObject(deposito);

            var stringContent = new StringContent(json);

            var response = await client.PostAsync($"{baseURL}/deposito?description={deposito.Description}&amount={deposito.Amount}", stringContent);

            var result = "";

            try
            {
                response.EnsureSuccessStatusCode();
                // Handle success
                result = await response.Content.ReadAsStringAsync();
            }
            catch (HttpRequestException)
            {
                // Handle error
                ViewBag.Json = await response.Content.ReadAsStringAsync();

                return(View());
            }

            ViewBag.Json = result;

            return(View());
        }
Example #4
0
        public IHttpActionResult getSelectedCredit(int creditId)
        {
            IList <branch>    branchList    = le.branches.ToList();
            IList <client>    clientList    = le.clients.ToList();
            IList <credit>    creditList    = le.credits.ToList();
            IList <parameter> parameterList = le.parameters.ToList();

            credit credit = creditList.Where(x => x.contract_no == creditId)
                            .FirstOrDefault();

            client client = clientList.Where(x => x.client_no == credit.client_no)
                            .FirstOrDefault();

            CreditViewModel creditModel = new CreditViewModel
            {
                Branches   = branchList,
                Parameters = parameterList,
                Credit     = credit,
                Client     = client,
                Currencies = new List <string>
                {
                    "TL",
                    "USD",
                    "EUR"
                }
            };


            return(Ok(creditModel));
        }
Example #5
0
        public ActionResult Pay(CreditViewModel credit)
        {
            var carts = getCarts();

            if (ModelState.IsValid)
            {
                foreach (var cart in carts)
                {
                    ProjectAccess access = new ProjectAccess();
                    access.UserId    = UserHelper.Current().Id;
                    access.ProjectId = cart.ProjectId;

                    Payment payment = new Payment();
                    payment.Amount        = cart.Project.Price;
                    payment.Date          = DateTime.Now;
                    payment.UserId        = UserHelper.Current().Id;
                    payment.ProjectAccess = access;
                    db.PaymentSet.Add(payment);

                    cart.Status = CartStatus.Paid;
                }

                db.SaveChanges();

                return(RedirectToAction("Success"));
            }

            ViewBag.Amount = carts.Sum(q => q.Project.Price);
            return(View("PayForm"));
        }
Example #6
0
        public ActionResult Credit(CreditViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                Console.WriteLine(model.DestinationAccountNumber);
                return(View(model));
            }
            if (ExisteDestino(model.DestinationAccountNumber))
            {
                SqlConnection sqlCon = new SqlConnection(cadenaConexion);

                //Monto de cuenta destino
                SqlCommand sqlCmd3 = new SqlCommand
                {
                    CommandText = "select Balance from AspNetUsers where AccountNumber='" + model.DestinationAccountNumber + "';",
                    Connection  = sqlCon
                };

                string consultadestino = "0";

                //este mensaje nunca deberia de imprimirse
                ViewBag.Message = String.Format("Aun no he realizado la transferencia\\n{0}", DateTime.Now.ToString());
                //lo puse para probar porque la estaba cagando en algo
                try
                {
                    sqlCon.Open();
                    consultadestino = sqlCmd3.ExecuteScalar().ToString();

                    double monto         = Convert.ToDouble(model.Amount);
                    string monto_destino = Convert.ToString(Convert.ToDouble(consultadestino) + monto);

                    //Actualiza monto actual de usuario destino
                    SqlCommand usuario_destino = new SqlCommand
                    {
                        CommandText = "UPDATE AspNetUsers SET Balance='" + monto_destino + "' WHERE AccountNumber='" + model.DestinationAccountNumber + "';",
                        Connection  = sqlCon
                    };
                    usuario_destino.ExecuteNonQuery();

                    ViewBag.Message = String.Format("Transferencia realizada con exito\\n Fecha y hora: {0}", DateTime.Now.ToString());
                }
                catch
                {
                    ViewBag.Message = String.Format("La estoy cagando\\n{0}", DateTime.Now.ToString());
                }
                finally
                {
                    if (sqlCon.State == ConnectionState.Open)
                    {
                        sqlCon.Close();
                    }
                }
                return(RedirectToAction("CheckBalance", "Account"));
            }
            else
            {
                ModelState.AddModelError("", "Numero de cuenta no existe.");
                return(View(model));
            }
        }
Example #7
0
 public void AllocationCredit(CreditViewModel model, string userId)
 {
     using (OnlineSaverEntities context = new OnlineSaverEntities())
     {
         //var creditList = context.SavingGoals.Where(x => (!x.CreditAllocations.Any() || x.CreditAllocations.Sum(y => y.AllocatedAmount) < x.Goal));
         var allocateGoalList = context.SavingGoals.Where(x => x.SavedAmount < x.Goal && x.UserId == userId);
         if (allocateGoalList.Any())
         {
             allocateGoalList = allocateGoalList.OrderBy(x => x.CreateDate);
             foreach (var goal in allocateGoalList)
             {
                 var amountNeedBeAllocated = goal.Goal - goal.SavedAmount;
                 if (model.CreditAmount >= amountNeedBeAllocated)
                 {
                     goal.SavedAmount   += amountNeedBeAllocated;
                     model.CreditAmount -= amountNeedBeAllocated.Value;
                 }
                 else
                 {
                     goal.SavedAmount  += model.CreditAmount;
                     model.CreditAmount = 0;
                 }
                 if (model.CreditAmount <= 0)
                 {
                     break;
                 }
             }
             context.SaveChanges();
         }
     }
 }
        public CreditPage()
        {
            var creditStore = new SQLiteCreditStore(DependencyService.Get <ISQLiteDb>());
            var pageService = new PageService();

            ViewModel = new CreditViewModel(creditStore, pageService);

            InitializeComponent();
        }
Example #9
0
        public double CalculateAnnuity(CreditViewModel creditModel)
        {
            double monthlyRate           = (creditModel.RatePerYear / 12) / 100;
            double periodNum             = creditModel.NumberOfPayments;
            double annuityCoefficient    = (monthlyRate * Math.Pow((1 + monthlyRate), periodNum)) / (Math.Pow((1 + monthlyRate), periodNum) - 1);
            double monthlyAnnuityPayment = annuityCoefficient * creditModel.CreditSum;

            return(monthlyAnnuityPayment);
        }
Example #10
0
 // GET: Credit
 public ActionResult Index(CreditViewModel mv)
 {
     mv.UserName = _userService.GetUserById(new UserDto {
         UserId = Convert.ToInt32(Session["UserId"])
     }).UserName;
     mv.Credit = Convert.ToDouble(_userService.GetUserCredit(new UserDto {
         UserName = mv.UserName
     }));
     return(View(new CreditViewModel {
         UserName = mv.UserName, Credit = mv.Credit
     }));
 }
Example #11
0
        public ShowModel ParseToShowModel(CreditViewModel creditModel)
        {
            var showModel          = new ShowModel();
            var annuityCoefficient = CalculateAnnuity(creditModel);

            showModel.PurchasePrice    = creditModel.CreditSum.ToString("N2");
            showModel.CreditTime       = creditModel.NumberOfPayments.ToString();
            showModel.MonthlyPayment   = annuityCoefficient.ToString("N2");
            showModel.CreditSum        = (creditModel.NumberOfPayments * annuityCoefficient).ToString("N2");
            showModel.TotalOverpayment = ((creditModel.NumberOfPayments * annuityCoefficient) - double.Parse(showModel.PurchasePrice)).ToString("N2");
            return(showModel);
        }
Example #12
0
        public IActionResult Index(CreditViewModel creditModel)
        {
            creditModel.NumberOfPayments *= creditModel.OptionValue; // Количество платежей умножаем на период 15 дней - 2 два раза больше плятежей за месяц
            var showModel = ParseToShowModel(creditModel);
            var showTable = AnnualPaymentSchedule(creditModel.CreditSum,
                                                  creditModel.RatePerYear,
                                                  creditModel.NumberOfPayments,
                                                  double.Parse(showModel.MonthlyPayment));

            var obj = new ResultViewModel(showModel, showTable);

            return(View($"Index2", obj));
        }
Example #13
0
        public async Task <IActionResult> Post([FromBody] CreditViewModel credit)
        {
            if (credit == null)
            {
                return(BadRequest());
            }

            await _creditWriteService.UpsertCredit(new CustomMapper <CreditViewModel, Credit>().Map(credit));

            var state = credit.Id <= 0 ? "added" : "updated";

            return(Ok($"Credit was {state}"));
        }
Example #14
0
 public void CreateCredit(CreditViewModel model)
 {
     using (OnlineSaverEntities context = new OnlineSaverEntities())
     {
         context.Credits.Add(new Credit()
         {
             Descrption   = model.Description,
             ImportAmount = model.CreditAmount,
             UserId       = model.UserId
         });
         context.SaveChanges();
     }
 }
Example #15
0
 public bool EnbleToCreateCredit(CreditViewModel model, string userId, out decimal needAllocatedAmount)
 {
     using (OnlineSaverEntities context = new OnlineSaverEntities())
     {
         var goals = context.SavingGoals.Where(x => x.UserId == userId);
         if (goals.Any())
         {
             needAllocatedAmount = goals.Sum(x => x.Goal) - goals.Sum(x => x.SavedAmount).Value;
             return(model.CreditAmount <= needAllocatedAmount);
         }
         needAllocatedAmount = 0;
         return(false);
     }
 }
Example #16
0
        // GET: 查看信誉评价
        public ActionResult Credit()
        {
            //获取当前用户id
            int usrId = (int)HttpContext.Session["usrId"];
            //新建视图模型
            CreditViewModel res = new CreditViewModel();

            using (SSDBEntities db = new SSDBEntities())
            {
                Users  u = db.Users.Where(X => X.UserId == usrId).FirstOrDefault();
                Assess a = db.Assess.Where(x => x.UserId == usrId).FirstOrDefault();
                res.assess = a;
                res.QQ     = u.QQ;
                res.Email  = u.Email;
                return(View(res));
            }
        }
        public async Task <IActionResult> PostCredit(string description, decimal amount)
        {
            if (!caller.Identity.IsAuthenticated)
            {
                return(BadRequest("User not authenticated"));
            }

            // retrieve the user info
            var userId        = int.Parse(caller.Claims.SingleOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value);
            var accountNumber = int.Parse(caller.Claims.SingleOrDefault(c => c.Type == "account_number").Value);
            var credit        = new CreditViewModel {
                UserId = userId, AccountNumber = accountNumber, Amount = amount, Description = description
            };

            var result = await accountAppServices.AddCredit(credit, CancellationToken.None);

            return(ValidationHandler(credit, result));
        }
Example #18
0
        public async Task <CreditViewModel> GetById(CreditId creditId)
        {
            var domainEvents = await _eventStore.GetEventsByStreamId(new CreditEventStreamId(creditId));

            if (domainEvents.Count == 0)
            {
                return(null);
            }

            var model = new CreditViewModel(creditId);

            foreach (var domainEvent in domainEvents.Cast <CreditDomainEvent>())
            {
                _projection.Apply(model, domainEvent);
            }

            return(model);
        }
Example #19
0
        public void Apply(CreditViewModel model, CreditDomainEvent domainEvent)
        {
            switch (domainEvent)
            {
            case CreditRegistered creditRegistered:
                model.LoanAmount         = creditRegistered.LoanAmount;
                model.OrganisationNumber = creditRegistered.OrganisationNumber;
                model.Balance            = Money.Create(0, creditRegistered.LoanAmount.Currency);
                break;

            case CreditRegisteredFromLoanApplication fromLoanApplication:
                model.ApplicationId = fromLoanApplication.LoanApplicationId;
                break;

            case DisbursementRegistered disbursementRegistered:
                model.Balance -= disbursementRegistered.Amount;
                break;
            }
        }
Example #20
0
        public static void PrintCredit(CreditViewModel model, ServiceClient repository)
        {
            ReportDataSet dsRep = new ReportDataSet();

            ReportDataSet.CreditDTRow dsCreditDtRowRow = dsRep.CreditDT.NewCreditDTRow();
            dsCreditDtRowRow.Fio       = model.UserName;
            dsCreditDtRowRow.Data      = model.DataStart;
            dsCreditDtRowRow.SummaFull = model.SummaFull.ToString();
            dsCreditDtRowRow.Stavka    = model.Stavka.ToString();
            dsCreditDtRowRow.TermMonth = model.TermMonth.ToString();
            dsCreditDtRowRow.IdCredit  = model.Id.ToString();

            dsRep.CreditDT.Rows.Add(dsCreditDtRowRow);

            List <Payment> payments = repository.GetPaymentsByIdCredit(model.Id).ToList();

            foreach (var item in payments)
            {
                ReportDataSet.PaymentDTRow dsPaymentDtRow = dsRep.PaymentDT.NewPaymentDTRow();
                dsPaymentDtRow.IdCredit    = model.Id.ToString();
                dsPaymentDtRow.NumberMonth = item.NumberMonth.ToString();
                dsPaymentDtRow.Data        = item.Data;
                dsPaymentDtRow.LostSumma   = item.LostSumma.ToString();
                dsPaymentDtRow.MainPay     = item.MainPay.ToString();
                dsPaymentDtRow.Percent     = item.Percent.ToString();
                dsPaymentDtRow.SummaMonth  = item.SummaMonth.ToString();
                dsRep.PaymentDT.Rows.Add(dsPaymentDtRow);
            }

            using (FastReport.Report report = new FastReport.Report())
            {
                report.StoreInResources = true;
                report.Load("Report\\CreditReport.frx");

                report.RegisterData((DataTable)dsRep.CreditDT, "CreditInfoList");
                report.GetDataSource("CreditInfoList").Enabled = true;
                report.RegisterData((DataTable)dsRep.PaymentDT, "PaymentList");
                report.GetDataSource("PaymentList").Enabled = true;
                //report.Design();
                report.Show();
            }
        }
Example #21
0
        public ActionResult Edit(int id)
        {
            CreditViewModel creditModel = new CreditViewModel();

            HttpClient hc = new HttpClient();

            hc.BaseAddress = new Uri("https://localhost:44300/api/ListsCredit/");
            var consumeApi = hc.GetAsync($"getSelectedCredit?creditId={id}");

            consumeApi.Wait();

            var readData = consumeApi.Result;

            if (readData.IsSuccessStatusCode)
            {
                var displayData = readData.Content.ReadAsAsync <CreditViewModel>();
                displayData.Wait();
                creditModel = displayData.Result;
            }
            return(View(creditModel));
        }
Example #22
0
        public ActionResult Edit(CreditViewModel creditModel)
        {
            HttpClient hc = new HttpClient();

            hc.BaseAddress = new Uri("https://localhost:44300/api/ListsCredit/");
            var insertRecord = hc.PutAsJsonAsync("ListsCredit", creditModel.Credit);

            insertRecord.Wait();

            var saveData = insertRecord.Result;

            if (saveData.IsSuccessStatusCode)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                ViewBag.message = "Kredi güncellenemedi";
            }
            return(View(creditModel));
        }
Example #23
0
 public ActionResult CreateCredit(CreditViewModel model)
 {
     if (ModelState.IsValid)
     {
         decimal needAllocateAmount;
         var     userId = User.Identity.GetUserId();
         if (creditService.EnbleToCreateCredit(model, userId, out needAllocateAmount))
         {
             model.UserId = userId;
             creditService.CreateCredit(model);
             creditService.AllocationCredit(model, model.UserId);
             TempData["CreditCreated"] = true;
             return(RedirectToAction("CreateCredit", "Home"));
         }
         else
         {
             ViewBag.CreditCreated      = false;
             ViewBag.NeedAllocateAmount = needAllocateAmount;
             return(View("CreateCredit", model));
         }
     }
     return(View("CreateCredit", model));
 }
Example #24
0
        //comboboxların doldurulması için; müşteri, şube ve döviz cinslerini listeler.
        public IHttpActionResult getEntityList()
        {
            IList <branch>         branchList = le.branches.ToList();
            IList <SelectListItem> clientList = le.clients.Where(x => x.authoriyId == 1)
                                                .Select(x => new SelectListItem
            {
                Value = x.client_no.ToString(),
                Text  = x.name + " " + x.surname
            }).ToList();

            CreditViewModel creditModel = new CreditViewModel
            {
                Clients    = clientList,
                Branches   = branchList,
                Currencies = new List <string>
                {
                    "TL",
                    "USD",
                    "EUR"
                }
            };

            return(Ok(creditModel));
        }
 public DepositResponse(CreditViewModel transaction)
 {
     Transaction = transaction;
 }
Example #26
0
 public CreditPage()
 {
     InitializeComponent();
     DataContext = new CreditViewModel();
 }
Example #27
0
        public async Task <Result> AddCredit(CreditViewModel credit, CancellationToken cancellationToken = default)
        {
            var request = mapper.Map <Commands.Credit.Request>(credit);

            return(await mediator.SendCommand(request, cancellationToken));
        }