public async Task <IActionResult> UpdateRoleCredential([FromRoute] long id, [FromBody] RoleCredential roleCredential) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != roleCredential.RId) { return(BadRequest()); } _context.Entry(roleCredential).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (Exception e) { if (!RoleCredentialExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> UpdateUserAccount([FromRoute] long id, [FromBody] UserAccount userAccount) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != userAccount.Id) { return(BadRequest()); } _context.Entry(userAccount).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (Exception e) { if (!UserAccountExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCredential([FromRoute] string token, [FromBody] Credential credential) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (token != credential.Token) { return(BadRequest()); } _context.Entry(credential).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CredentialExists(token)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutSong([FromRoute] long id, [FromBody] Song song) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != song.Id) { return(BadRequest()); } _context.Entry(song).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SongExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCustumer(int id, Custumer custumer) { if (id != custumer.Id) { return(BadRequest()); } _context.Entry(custumer).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustumerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutUserInformation([FromRoute] string email, [FromBody] UserInformation userInformation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (email != userInformation.Email) { return(BadRequest()); } _context.Entry(userInformation).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserInformationExists(email)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <IEnumerable <User> > > PostUser(User u) { using (Context) { foreach (User e in Context.Users) { if (e.Id == u.Id) { return(BadRequest("Error: User not created. (User by that ID already exists)")); } } Context.Users.Add(u); await Context.SaveChangesAsync(); return(Ok("New user created: " + u)); } }