public async Task <IActionResult> UpdateAPost(int postId, Post post) { if (postId != post.PostId) { return(BadRequest()); } context.Entry(post).State = EntityState.Modified; try { await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PostExists(postId)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IActionResult PutCategory(int id, [FromBody] Category category) { if (id != category.CategoryId) { return(BadRequest()); } context.Entry(category).State = EntityState.Modified; try { context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> UpdateAnEmployee(int id, Employee employee) { context.Entry(employee).State = EntityState.Modified; try { await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { return(NotFound(new { message = Properties.Resources.FailureMessage })); } catch (Exception) { return(Ok(new { message = Properties.Resources.FailureMessage })); } return(Ok(new { message = Properties.Resources.EmployeeDetailsUpdatedMessage })); }