예제 #1
0
        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));
        }
예제 #2
0
        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));
        }