public async Task <IActionResult> PutProvider(int id, Provider provider) { if (id != provider.Id) { return(BadRequest()); } _context.Entry(provider).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProviderExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutOperationType(int id, OperationType operationType) { if (id != operationType.Id) { return(BadRequest()); } _context.Entry(operationType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OperationTypeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCategory(int id, Category category) { if (id != category.Id) { return(BadRequest()); } _context.Entry(category).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutUser(int id, User user) { if (id != user.Id) { return(BadRequest()); } var found = await _context.User.Where(x => x.Id == id).FirstOrDefaultAsync(); found.Name = user.Name; found.RoleId = user.RoleId; found.Age = user.Age; found.Email = user.Email; found.UserName = user.UserName; found.Active = user.Active; if (found.Password != user.Password) { user.Password = BCrypt.Net.BCrypt.HashPassword(user.Password); } _context.Entry(found).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }