Ejemplo n.º 1
0
        public IActionResult Create()
        {
            CustomerAccountPrefix       prefix       = new CustomerAccountPrefix();
            Dictionary <string, string> customerType = prefix.GetDictionary();
            SelectList selectListItems = new SelectList((IEnumerable)customerType, "Value", "Key");

            ViewData["customerType"] = selectListItems;
            return(View());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create(Customer customer)
        {
            if (!ModelState.IsValid)
            {
                CustomerAccountPrefix       prefix       = new CustomerAccountPrefix();
                Dictionary <string, string> customerType = prefix.GetDictionary();
                SelectList selectListItems = new SelectList((IEnumerable)customerType, "Value", "Key");
                ViewData["customerType"] = selectListItems;
                return(View(customer));
            }
            // Create Customer
            if (customer.AccountNumber.Length == 2)
            {
                // Code Provided, Append Number
                customer.AccountNumber += DateTimeOffset.Now.ToUnixTimeSeconds();
            }
            _context.Customers.Add(customer);
            await _context.SaveChangesAsync();

            TempData["Success"] = "Customer Created Successfully";
            return(RedirectToAction(nameof(Index)));
        }