Exemplo n.º 1
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Customerid,Email,PhoneFull,Phone,BirthDay")] CustomersAdditional customersAdditional)
        {
            if (id != customersAdditional.Customerid)
            {
                return(NotFound());
            }

            var customers = await _context.Customers
                            .SingleOrDefaultAsync(m => m.CustomerId == id);

            ViewData["customerName"] = customers.FirstName + " " + customers.LastName;

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customersAdditional);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomersAdditionalExists(customersAdditional.Customerid))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Details), new { id = customersAdditional.Customerid }));
            }
            return(View(customersAdditional));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Customerid,Email,PhoneFull,Phone,BirthDay")] CustomersAdditional customersAdditional)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customersAdditional);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Details), new { id = customersAdditional.Customerid }));
            }
            return(View(customersAdditional));
        }