Example #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Customers.Add(Customer);
            await _context.SaveChangesAsync();

            return(RedirectToPage("/MyAccount"));
        }
Example #2
0
        public async Task OnPostDeleteTraveler(string id)
        {
            var traveler = _context.Customers.Include(p => p.Passport).FirstOrDefault(x => x.CustomerId == id);
            var passport = traveler.Passport;

            if (traveler != null)
            {
                _context.Customers.Remove(traveler);
                _context.Passports.Remove(passport);

                await _context.SaveChangesAsync();
            }

            Response.Redirect("/MyAccount");
        }
Example #3
0
 public async Task AddObject(Customer o)
 {
     dbSet.Add(o);
     await _context.SaveChangesAsync();
 }