public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); if (ModelState.IsValid) { var user = new IdentityUser { UserName = Input.Email, Email = Input.Email }; var result = await _userManager.CreateAsync(user, Input.Password); if (result.Succeeded) { _logger.LogInformation("User created a new account with password."); await UserServices.CreateUser(Input.Email); var idUser = UserServices.GetUserByMail(Input.Email).Id; var listeId = TableServices.CreateTableForNewUser(idUser); ChampsService.CreateChampsForNewUser(listeId); await _userManager.AddToRoleAsync(user, "Utilisateur"); await _signInManager.SignInAsync(user, isPersistent : false); return(LocalRedirect(returnUrl)); } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } // If we got this far, something failed, redisplay form return(Page()); }
public IActionResult DeleteChampsToTable(TableForDeleteChampsViewModel champs) { foreach (var id in champs.ListeSelectId) { ChampsService.DeleteChamps(id); } return(RedirectToAction(nameof(HomeController.Index))); }
public IActionResult AddChampsToTable(AddChampsToTableViewModel addChampsToTableVM) { if (ModelState.IsValid) { ChampsService.AddChampsToTable(addChampsToTableVM.Name, addChampsToTableVM.IdTable, addChampsToTableVM.Table, addChampsToTableVM.Type); return(RedirectToAction(nameof(HomeController.Index))); } return(View()); }
public IActionResult EditChamps(int id) { var champstoEdit = new TableUserViewModel() { Name = ChampsService.GetChamps(id).Name, Id = id, }; return(View(champstoEdit)); }
public IActionResult AddValues(int id) { var newCreateValueVM = new CreateValueViewModel() { IdTable = id, ListeChamps = ChampsService.GetChampsFromTable(id).Select(w => new ChampsCreateValueViewModel() { Id = w.Id, Nom = w.Name, }).ToList(), }; return(View(newCreateValueVM)); }
public IActionResult DeleteChampsToTable(int id) { var champs = new TableForDeleteChampsViewModel { Id = id, ListeChamps = ChampsService.GetChampsFromTable(id).Select(w => new ChampViewModel { Id = w.Id, Nom = w.Name, }).ToList() }; return(View(champs)); }
/// <summary> /// Montre les champs et les valeurs d'une table pour un utilisateur séléctionné /// </summary> /// <param name="id"></param> /// <returns></returns> public IActionResult TableIndex(int id) { var indexTable = new IndexTableViewModel() { NameTable = TableService.GetTableById(id).Nom, ListeChamps = ChampsService.GetChampsFromTable(id).Select(p => new ChampViewModel { Id = p.Id, Nom = p.Name, }).ToList(), ListeLiaison = LiaisonValueService.GetAllLiaison().Where(p => p.IdTable == id).Select(w => new LiaisonTableIndexViewModel { Id = w.Id, ListeValue = ValueService.GetValueFromLiaison(w.Id).Select(a => new ValuesViewModel { Nom = a.Name, IdChamps = a.ChampsId }).ToList(), }).ToList(), }; return(View(indexTable)); }
public IActionResult EditChamps(TableUserViewModel champsEdit) { ChampsService.UpdateChamps(champsEdit.Id, champsEdit.Name); return(RedirectToAction(nameof(HomeController.Index))); }