Ejemplo n.º 1
0
        public async Task <IActionResult> Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                User user = await _context.Users.FirstOrDefaultAsync(u => u.Email == model.Email);

                if (user == null)
                {
                    user = new User {
                        FirstName = model.FirstName, LastName = model.SecondName, Patronymic = model.Patronymic, Email = model.Email, Address = model.Address, Phone = model.Phone, ProbabilityOfInsolvency = model.ProbabilityOfInsolvency, Password = model.Password, TypeOfUser = "******"
                    };

                    _context.Users.Add(user);

                    //User getUser = await _context.Users.FirstOrDefaultAsync(u => u.Email == model.Email && u.FirstName == model.FirstName && u.LastName == model.SecondName);
                    await _context.SaveChangesAsync();

                    //Account account = new Account { Login = model.Email, Password = model.Password, IdNavigation = user };
                    //_context.Accounts.Add(account);
                    //await _context.SaveChangesAsync();

                    await Authenticate(user);

                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ModelState.AddModelError("", "Incorrect email or password");
                }
            }
            return(View(model));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create(
            [Bind("DateOfApplicationSubmission,LoanSize,TypeOfLoanId")]
            SubmittedApplication submittedApplication)
        {
            SubmittedApplication subApp = await _context.SubmittedApplications.FirstOrDefaultAsync();

            if (ModelState.IsValid)
            {
                subApp = new SubmittedApplication {
                    DateOfApplicationSubmission = submittedApplication.DateOfApplicationSubmission,
                    LoanSize     = submittedApplication.LoanSize,
                    Status       = "In review",
                    UserId       = Int32.Parse(Request.Cookies["UserId"]),
                    TypeOfLoanId = submittedApplication.TypeOfLoanId
                };
                _context.SubmittedApplications.Add(subApp);
                //_context.Add(submittedApplication);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            //ViewData["TypeOfLoanId"] = new SelectList(_context.TypeOfLoans, "Id", "TypeOfLoanRate", submittedApplication.TypeOfLoanId);
            //ViewData["UserId"] = new SelectList(_context.Users, "Id", "Address", submittedApplication.UserId);
            return(View(submittedApplication));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Patronymic,Email,Address,Phone,ProbabilityOfInsolvency,TypeOfUser")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("Id,TypeOfLoanRate,Percent")] TypeOfLoan typeOfLoan)
        {
            if (ModelState.IsValid)
            {
                _context.Add(typeOfLoan);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(typeOfLoan));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("Id,Date,PaymentAmount,UserId")] DebtPayment debtPayment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(debtPayment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "Address", debtPayment.UserId);
            return(View(debtPayment));
        }