예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Email,Address1,Address2,City,State,ZipCode,Phone,DateAdded")] ABContacts aBContacts)
        {
            if (id != aBContacts.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(aBContacts);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ABContactsExists(aBContacts.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(aBContacts));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("FirstName,LastName,Email,Address1,Address2,City,State,ZipCode,Phone")] ABContacts aBContacts)
        {
            if (ModelState.IsValid)
            {
                aBContacts.DateAdded = DateTime.Now;
                _context.Add(aBContacts);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(aBContacts));
        }