Esempio n. 1
0
        public async Task <IActionResult> Create([Bind("bill_id,date_generated,due_date,cust_ids,cust_id,premise_id,address,amount,status")] Bill_Information bill_Information)
        {
            if (ModelState.IsValid)
            {
                JPSUser data = await userManager.FindByIdAsync(bill_Information.cust_id);

                bill_Information.premise_id = data.premise_number;

                var address = await _context.PREMISE_DETAILS.FirstOrDefaultAsync(m => m.ID == "PREPJPS200");

                bill_Information.address = address.LOCATION_ADDRESS;

                BillDatabaseModel model = new BillDatabaseModel
                {
                    address        = bill_Information.address,
                    amount         = bill_Information.amount,
                    bill_id        = bill_Information.bill_id,
                    cust_id        = bill_Information.cust_id,
                    date_generated = bill_Information.date_generated,
                    due_date       = bill_Information.due_date,
                    premise_id     = bill_Information.premise_id,
                    status         = bill_Information.status
                };

                _context.Bill_Information.Add(model);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(bill_Information));
        }
Esempio n. 2
0
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            returnUrl      = returnUrl ?? Url.Content("~/");
            ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
            if (ModelState.IsValid)
            {
                var user = new JPSUser {
                    UserName = Input.username, Email = Input.Email, FirstName = Input.First_Name, LastName = Input.Last_Name, premise_number = Input.premise_number
                };
                var result = await _userManager.CreateAsync(user, Input.Password);

                if (result.Succeeded)
                {
                    await _userManager.AddToRoleAsync(user, "Customer");

                    _logger.LogInformation("User created a new account with password.");

                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
                    var callbackUrl = Url.Page(
                        "/Account/ConfirmEmail",
                        pageHandler: null,
                        values: new { area = "Identity", userId = user.Id, code = code, returnUrl = returnUrl },
                        protocol: Request.Scheme);

                    await _emailSender.SendEmailAsync(Input.Email, "Confirm your email",
                                                      $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");

                    if (_userManager.Options.SignIn.RequireConfirmedAccount)
                    {
                        return(RedirectToPage("RegisterConfirmation", new { email = Input.Email, returnUrl = returnUrl }));
                    }
                    else
                    {
                        await _signInManager.SignInAsync(user, isPersistent : false);

                        return(LocalRedirect(returnUrl));
                    }
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            // If we got this far, something failed, redisplay form
            return(Page());
        }
Esempio n. 3
0
        public async Task <IActionResult> DeleteUser(JPSUser model)
        {
            var user = await userManager.FindByIdAsync(model.Id);

            if (user != null)
            {
                user.UserName = model.UserName;

                var result = await userManager.DeleteAsync(user);

                if (result.Succeeded)
                {
                    return(RedirectToAction("ListUsers"));
                }

                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError("", error.Description);
                }
            }
            return(View("ListUsers"));
        }