public async Task <IActionResult> Edit(int id, [Bind("Customer,IBAN,Birth_date,sex")] Boeker boeker) { if (id != boeker.Customer) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(boeker); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BoekerExists(boeker.Customer)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(boeker)); }
public async Task <IActionResult> RegisterBoeker(RegisterBoekerViewModel model) { if (signInManager.IsSignedIn(User)) { if (ModelState.IsValid) { var customerAssociated = (from c in _context.Customer where c.Username == model.Email select c).FirstOrDefault(); var boeker = new Boeker { Customer = customerAssociated.Id, IBAN = model.IBAN, Birth_date = model.Birth_date, sex = model.Sex }; _context.Add(boeker); await _context.SaveChangesAsync(); return(RedirectToAction("Index", "Home")); } } else { return(View("Login", "Home")); } return(View(model)); }
public async Task <IActionResult> Create([Bind("Customer,IBAN,Birth_date,sex")] Boeker boeker) { if (ModelState.IsValid) { _context.Add(boeker); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(boeker)); }