コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Number,TypePhoneId,ContactId")] Phone phone)
        {
            if (id != phone.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(phone);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PhoneExists(phone.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Details", "Contact", new { id = phone.ContactId }));
            }
            ViewData["ContactId"]   = new SelectList(_context.Contacts, "Id", "Name", phone.ContactId);
            ViewData["TypePhoneId"] = new SelectList(_context.TypePhones, "Id", "Name", phone.TypePhoneId);
            return(PartialView(phone));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Surname,Name,Patronymic,Address,Job,Position,Email,Skype,UserId,GroupId")] 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("Index", "Home"));
            }
            ViewData["ContactId"] = id;
            ViewData["GroupId"]   = new SelectList(_context.Groups, "Id", "Name", contact.GroupId);

            return(View(contact));
        }
コード例 #3
0
ファイル: DictController.cs プロジェクト: Nikkooly/aspLab
 public ActionResult UpdateSave(string id, string surname, string telephone)
 {
     phoneBookContext = new PhoneBookContext();
     phoneBookContext.Update(Guid.Parse(id), surname, telephone);
     ViewBag.PhoneBooks = phoneBookContext.PhoneBooks;
     return(View("Index"));
 }
コード例 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("ContactId,Email,FirstName,LastName,Phone")] Contacts contacts)
        {
            if (id != contacts.ContactId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(contacts);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ContactsExists(contacts.ContactId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(contacts));
        }
コード例 #5
0
        public async Task <IActionResult> Edit(int id, [Bind("ClienteId,Nome,Cpf,Cpnj,Email,TelefoneCelular,TelefoneResidencial,TelefoneComercial,Endereco")] Clientes clientes)
        {
            if (id != clientes.ClienteId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(clientes);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClientesExists(clientes.ClienteId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(clientes));
        }
コード例 #6
0
        public async Task <IActionResult> Edit(long id, [Bind("Id,Type,FirstName,LastName,Image,Address,Description")] Person person)
        {
            if (id != person.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(person);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PersonExists(person.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(person));
        }
コード例 #7
0
        public async Task <IActionResult> Edit(long id, [Bind("Id,Type,Number,PersonId")] Phone phone)
        {
            if (id != phone.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(phone);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PhoneExists(phone.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(new RedirectToActionResult(nameof(Index), "Phones", new { pid = phone.PersonId }));
            }
            ViewData["PersonId"] = phone.PersonId;
            return(View(phone));
        }
コード例 #8
0
 public ActionResult UpdateSave(string id, string surname, string telephone)
 {
     phoneBookContext = new PhoneBookContext(Server.MapPath("~/Models/Data.json"));
     phoneBookContext.Update(Guid.Parse(id), surname, telephone);
     ViewBag.PhoneBooks = phoneBookContext.PhoneBooks;
     return(View("Index"));
 }
コード例 #9
0
        public IActionResult Update(DTO.Person person)
        {
            using (var context = new PhoneBookContext())
            {
                var modelPerson = _mapper.Map <Person>(person);

                if (modelPerson != null)
                {
                    context.Update(modelPerson);
                    context.SaveChanges();

                    return(Ok());
                }
            }

            return(NotFound());
        }
コード例 #10
0
ファイル: GroupController.cs プロジェクト: IGULOL/PhoneBook
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Group @group)
        {
            var  name = User.Identity.Name;
            User user = _context.Users.FirstOrDefault(u => u.UserName == name);

            if (user != null)
            {
                ViewData["NameUser"] = user.Surname + " " + user.Name;
            }

            if (id != @group.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(@group);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GroupExists(@group.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(@group));
        }