public IActionResult CreateUserFichier([FromBody] FichierCentral UserModel) { UserModel.DateCreation = DateTime.Now; UserModel.ProfilsID = 2; UserModel.UserId = Guid.NewGuid(); if (!ModelState.IsValid) { return(BadRequest(UserModel)); } try { List <FichierCentral> listAllUser = GetFicheCentral(); if (listAllUser.Where(x => x.Email == UserModel.Email).Count() > 0) { return(Json(new { isFailed = "cette adresse mail est déje utiliser" })); } context.FichierCentral.Add(UserModel); context.SaveChanges(); } catch (DbUpdateException exception) { return(BadRequest(new { message = exception.Message })); } return(Ok()); }
public IActionResult UpdateUser(long id, [FromBody] FichierCentral UserFichier) { UserFichier.FichierCentralID = id; try { context.FichierCentral.Update(UserFichier); return(Ok()); } catch (DbUpdateException exception) { return(BadRequest(new { message = exception.Message })); } }
public async Task <IActionResult> Login([FromBody] FichierCentral user) { if (user.Login == null || user.Password == null) { return(BadRequest()); } var result = await _signInManager.PasswordSignInAsync(user.Login, user.Password, isPersistent : false, lockoutOnFailure : false); if (!result.Succeeded) { return(NotFound()); } return(Ok()); }
public IActionResult CreateAbonnementUser([FromBody] FichierCentral UserModel, long id) { UserModel.FichierCentralID = id; UserModel.ProfilsID = 2; Abonnements Abonnement = new Abonnements(); Abonnement.AbonnementsID = UserModel.AbonnementsID; Abonnement.pkAbonne = UserModel.FichierCentralID; Abonnement.DateDebut = DateTime.Now; if (UserModel.AbonnementsID == 1) { Abonnement.DateFin = DateTime.Today.AddMonths(1); Abonnement.Prix_Abonnement = 10; Abonnement.Abonnement = "abonnement-1-mois"; } if (UserModel.AbonnementsID == 2) { Abonnement.DateFin = DateTime.Today.AddYears(1); Abonnement.Prix_Abonnement = 100; Abonnement.Abonnement = "abonnement-1-ans"; } if (UserModel.AbonnementsID == 3) { Abonnement.DateFin = DateTime.Today.AddYears(2); Abonnement.Prix_Abonnement = 180; Abonnement.Abonnement = "abonnement-2-ans"; } if (UserModel.AbonnementsID != 0) { try { context.FichierCentral.Update(UserModel); context.Abonnements.Add(Abonnement); context.SaveChanges(); } catch (DbUpdateException exception) { return(BadRequest(new { message = exception.Message })); } return(Ok()); } return(Json(new { isFailed = "manque de pk abonnement pour creer un abonnement" })); }
public IActionResult DeleteUser(long id) { FichierCentral FichierUser = context.FichierCentral.Find(id); if (FichierUser == null) { return(NotFound()); } else { try { context.FichierCentral.Remove(FichierUser); context.SaveChanges(); } catch (DbUpdateException exception) { return(BadRequest(new { message = exception.Message })); } return(Ok()); } }