Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Phone,Email,AddressId")] Contact contact)
        {
            if (id != contact.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(contact);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ContactExists(contact.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(contact));
        }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Phone,Email,AddressId")] Contact contact)
        {
            if (ModelState.IsValid)
            {
                //Contact.AddressId = addressId;
                _context.Add(contact);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(contact));
        }
Exemple #3
0
        public void FindContact(int?id)
        {
            if (id == null)
            {
                //return ControllerBase.NotFound();
            }


            while (id == DatabaseManager.ContactId)
            {
                Contact contactdetails = _context.Contacts.SingleOrDefault(c => c.Id == DatabaseManager.ContactId);
                string  fname          = contactdetails.FirstName;
                string  lname          = contactdetails.LastName;

                DatabaseManager.ContactDetailsList = new List <string> {
                    fname + " " + lname
                };
            }
        }