public IActionResult AddToBlacklist(int customerId) { DonorCustomer donor = checkForExisting.GetCustomer(context, customerId); if (donor == null) { return(Redirect("/")); } AddtoBlacklistViewModel model = new AddtoBlacklistViewModel() { Customer = donor }; return(View(model)); }
public IActionResult AddToBlacklist(AddtoBlacklistViewModel model) { Blacklist checkBlacklist = checkForExisting.GetBlacklistedCustomerById(context, model.Customer.ID); if (ModelState.IsValid && checkBlacklist == null) { Blacklist blacklistedPerson = new Blacklist { DonorCustomerID = model.Customer.ID, Reason = model.Reason }; context.Add(blacklistedPerson); context.SaveChanges(); return(Redirect("/Blacklist")); } return(View(model)); }