public async Task <IActionResult> Edit(Guid id, [Bind("Id,Nome,Email")] Cliente cliente) { if (id != cliente.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cliente); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClienteExists(cliente.Id)) { return(NotFound()); } throw; } return(RedirectToAction(nameof(Index))); } return(View(cliente)); }
public async Task <RxJob> UpdateAsync(RxJob job) { _context.Update(job); await _context.SaveChangesAsync(); return(job); }
public async Task <IActionResult> Edit(int id, [Bind("Id,BlogId,Url")] Blog blog) { if (id != blog.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(blog); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BlogExists(blog.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(blog)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email,Password,Address,UserType")] User user) { if (id != user.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(user.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,De_Id,Em_Code,FirstName,LastName,BirthDate,Phone,IdentityCardNumber,Sex,Address,Image,Status")] Employee employee) { if (id != employee.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(employee); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(employee.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(employee)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,DOB")] Owner owner) { if (id != owner.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(owner); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OwnerExists(owner.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(owner)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Name,UserName,Password")] SiteUser siteUser) { if (id != siteUser.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(siteUser); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SiteUserExists(siteUser.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(siteUser)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Location")] Attendee attendee) { if (id != attendee.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(attendee); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AttendeeExists(attendee.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(attendee)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Name,SiteUserId")] Course course) { if (id != course.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(course); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CourseExists(course.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["SiteUserId"] = new SelectList(_context.Siteusers, "ID", "Name", course.SiteUserId); return(View(course)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description,Status")] Department department) { if (id != department.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(department); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DepartmentExists(department.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(department)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Valor,Gratuito,Descricao,Data")] Evento evento) { if (id != evento.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(evento); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EventoExists(evento.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(evento)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Age")] Pet pet) { if (id != pet.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(pet); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PetExists(pet.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(pet)); }
/// </inheritdoc> public async Task <ItemDto> UpdateItemAsync(int id, ItemRequest request) { var item = await _context.Items.FindAsync(id); if (item == null) { throw new NotFoundException($"Item with {nameof(id)}: {id} not found"); } _mapper.Map(request, item); _context.Update(item); await _context.SaveChangesAsync(); return(_mapper.Map <ItemDto>(item)); }
public async Task <IActionResult> Edit(int id, BookClass obj) { if (id != obj.id) { return(NotFound()); } if (ModelState.IsValid) { _Context.Update(obj); await _Context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(obj)); }
/// <summary> /// Updates a contact /// </summary> /// <param name="c"></param> /// <returns></returns> public async Task EditContact(Contact c) { try { var contact = await _demoContext.Contacts.FirstOrDefaultAsync(v => v.ContactId == c.ContactId); contact.Email = c.Email; contact.Name = c.Name; contact.Phone = c.Phone; _demoContext.Update(contact); await _demoContext.SaveChangesAsync(); } catch (Exception) { throw; } }
public void UpdateProduct(Product product) { _context.Update(product); }
public IActionResult Update(Employee employee) { _context.Update(employee); _context.SaveChanges(); return(Ok(employee)); }