public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var user = await _context.Users.FindAsync(id);

            if (user == null)
            {
                return(NotFound());
            }

            try
            {
                _context.Users.Remove(user);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }
            catch (DbUpdateException)
            {
                return(RedirectToAction("./Delete",
                                        new { id, saveChangesError = true }));
            }
        }
Esempio n. 2
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Payment).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PaymentExists(Payment.PaymentID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Purchases.Add(Purchase);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Esempio n. 4
0
        public async Task <IActionResult> OnPostAsync()
        {
            var emptyPayment = new Payment();

            if (await TryUpdateModelAsync <Payment>(
                    emptyPayment,
                    "payment", // Prefix for form value.
                    p => p.PaymentSum, p => p.PaymentSum, p => p.UserID))
            {
                _context.Payments.Add(emptyPayment);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }

            return(Page());
        }
Esempio n. 5
0
        public async Task <IActionResult> OnPostAsync()
        {
            var emptyUser = new User();

            if (await TryUpdateModelAsync <User>(
                    emptyUser,
                    "user", // Prefix for form value.
                    u => u.FirstMidName, u => u.LastName))
            {
                _context.Users.Add(emptyUser);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }

            return(Page());
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Payment = await _context.Payments.FindAsync(id);

            if (Payment != null)
            {
                _context.Payments.Remove(Payment);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Esempio n. 7
0
        public async Task <IActionResult> OnPostAsync(int id)
        {
            var UserToUpdate = await _context.Users.FindAsync(id);

            if (UserToUpdate == null)
            {
                return(NotFound());
            }

            if (await TryUpdateModelAsync <User>(
                    UserToUpdate,
                    "user",
                    u => u.FirstMidName, u => u.LastName, u => u.Email, u => u.Password))
            {
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }

            return(Page());
        }