public async Task <IActionResult> PutProduit(int id, Produit produit) { if (id != produit.Id) { return(BadRequest()); } _context.Entry(produit).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProduitExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutListeClientCommercial(int id, ListeClientCommercial listeClientCommercial) { if (id != listeClientCommercial.Id) { return(BadRequest()); } _context.Entry(listeClientCommercial).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ListeClientCommercialExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCoordonnee(int id, Coordonnee coordonnee) { if (id != coordonnee.Id) { return(BadRequest()); } _context.Entry(coordonnee).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CoordonneeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <Utilisateur> > Login([FromBody] Utilisateur user) { var ph = new PasswordHasher(); var providedPassword = user.Password; user = await _context.Utilisateur.Where(u => u.Email == user.Email).FirstOrDefaultAsync(); var validPassword = ph.VerifyHashedPassword(user.Password, providedPassword); if (user != null && validPassword == Microsoft.AspNet.Identity.PasswordVerificationResult.Success) { var role = await _context.Roles.Where(r => r.Id == user.RoleId).FirstOrDefaultAsync(); user.AccessToken = GenerateAccessToken(user.Id, role.NomRole); await _context.SaveChangesAsync(); } return(user); }