Example #1
0
        public IActionResult ManageCustomers()
        {
            var customers = _dbContext.Customers.Where(x => x.DeleteDate.HasValue == false).ToList();

            var model = new ManageCustomersModel
            {
                Customers     = customers,
                StatusMessage = StatusMessage
            };

            return(View(model));
        }
Example #2
0
        public IActionResult ManageCustomers()
        {
            var customers = _dbContext.Customers.ToList();

            var model = new ManageCustomersModel
            {
                Customers     = customers,
                StatusMessage = StatusMessage
            };

            return(View(model));
        }
Example #3
0
        public async Task <IActionResult> ManageCustomers(ManageCustomersModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            _dbContext.Customers.Add(model.Customer);
            await _dbContext.SaveChangesAsync();

            StatusMessage = "Company added";
            return(RedirectToAction(nameof(ManageCustomers)));
        }