public async Task <IActionResult> Edit(int id, [Bind("ID,FirstName,LastName,Address,City,PIN,DateOfBirth,Email,IsEmployee,IsVolunteer,IsOutsorced")] 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)); }
public IActionResult Put([FromBody] Product entity) { IActionResult ret = null; try { //using (var db = new LoginDbContext()) //{ if (entity != null) { db.Update(entity); db.SaveChanges(); ret = StatusCode(StatusCodes.Status200OK, entity); } else { ret = StatusCode(StatusCodes.Status400BadRequest, "Invalid object passed to PUT method"); } // } } catch (Exception ex) { ret = HandleException(ex, "Exception trying to update product: " + entity.ProductId.ToString()); } return(ret); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Gender,Console")] Game game) { if (id != game.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(game); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GameExists(game.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(game)); }