private void Activities_Load(object sender, EventArgs e) { // bind data source to db using (ClubDbContext context = new ClubDbContext()) { adherentBindingSource.DataSource = context.Adherents.ToList(); seanceBindingSource.DataSource = context.Seances.ToList(); // Bind combobox datasource to db if (activities.Count == 0) { var activityNamesInDb = context.Activites.ToList(); activities.Add("Choisir Votre Discipline"); foreach (var activity in activityNamesInDb) { activities.Add(activity.Nom); } // bind data to the cb collection of values ActivitiesCB.DataSource = activities; } } // To display title of cb ActivitiesCB.SelectedIndex = 0; formEnabled(false); formTbInitializeText(); }
private void PayementBtn_Click(object sender, EventArgs e) { var adherentToPay = adherentBindingSource.Current as Adherent; if (adherentToPay == null) { UserErrors.Add("Veuillez séléctionner un adhérent pour éffectuer le payement!"); } if (ExpirationDate.Value.Date + ExpirationTime.Value.TimeOfDay < DateTime.Now) { UserErrors.Add("Veuillez Entrer une date d'éxpiration valide !"); } if (UserErrors.Count > 0) { MetroFramework.MetroMessageBox.Show(this, string.Join("\n", UserErrors), "Données Non Valides", MessageBoxButtons.OK, MessageBoxIcon.Error); // Clear errors for another use and quit UserErrors.Clear(); return; } using (ClubDbContext context = new ClubDbContext()) { var UserInDb = context.Users.SingleOrDefault(u => u.AdherentId == adherentToPay.CodeAdh); var CorrespondingAdherent = context.Adherents.SingleOrDefault(a => a.CodeAdh == adherentToPay.CodeAdh); UserInDb.Role = User.Client; CorrespondingAdherent.ExpirationDate = ExpirationDate.Value.Date + ExpirationTime.Value.TimeOfDay; context.SaveChanges(); } Subscribtions_Load(sender, e); }
private void Coachs_Load(object sender, EventArgs e) { // bind data source to db using (ClubDbContext context = new ClubDbContext()) { coachBindingSource.DataSource = context.Coaches.ToList(); seanceBindingSource.DataSource = context.Seances.ToList(); if (activities.Count == 0) { var activityNamesInDb = context.Activites.ToList(); activities.Add("Choisir Votre Discipline"); foreach (var activity in activityNamesInDb) { activities.Add(activity.Nom); } // bind data to the cb collection of values activitiesCB.DataSource = activities; } currentCoach = coachBindingSource.Current as Coach; currentSeance = seanceBindingSource.Current as Seance; } // disable form for input security control formEnabled(false); // disable affecter dicipline label AffecterDicipline.Enabled = false; AffecterDicipline.ForeColor = Color.White; }
// bind the second cb with coachs in db related to this activity private async void ActivitiesCB_SelectedIndexChanged(object sender, EventArgs e) { try { if (ActivitiesCB.SelectedValue == null || ActivitiesCB.SelectedValue.ToString() == "Activités") { return; } coaches.Clear(); coaches.Add("Coachs"); using (ClubDbContext context = new ClubDbContext()) { var SelectedActivity = await context.Activites.Include(a => a.Coachs).SingleOrDefaultAsync(a => a.Nom == ActivitiesCB.SelectedValue.ToString()); foreach (var coach in SelectedActivity.Coachs) { coaches.Add(coach.Nom + " " + coach.Prenom); } } // bind selected activity coachs to the scnd cb CoachsCB.DataSource = coaches; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void SubmitBtn_Click(object sender, EventArgs e) { ICollection <Activite> preffered = new HashSet <Activite>(); // Perform Submit Logic (set the role to Non Payed Client !) :) try { if (activiteBindingSource.Count != 0) { using (ClubDbContext context = new ClubDbContext()) { context.Users.SingleOrDefault(u => u.Id == currenUser.Id).Role = User.NonPayedClient; context.SaveChanges(); } } else { MetroFramework.MetroMessageBox.Show(this, "Veuillez" + "remplire votre liste des Activités préfférés!", "Données Non Valides", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message); } // call the event OnSetPrefferedActivities(); }
private void Subscribtions_Load(object sender, EventArgs e) { using (ClubDbContext context = new ClubDbContext()) { var NonPayedAdherents = context.Users .Where(u => u.Role == User.NonPayedClient || u.Role == User.NonRegisteredClient) .Select(u => u.Adherent) .ToList(); var SubscriptionsExpiringThisMounth = new BindingList <Adherent>(); var adherentsInDb = context.Adherents.ToList(); foreach (Adherent adh in adherentsInDb) { if (Expiration(adh.ExpirationDate)) { SubscriptionsExpiringThisMounth.Add(adh); } } adherentBindingSource.DataSource = NonPayedAdherents; adherentBindingSource1.DataSource = SubscriptionsExpiringThisMounth; ExpirationDate.Value = DateTime.Now.Date; ExpirationTime.Value = DateTime.Now.Date + DateTime.Now.TimeOfDay; } }
private void DeleteActivityBtn_Click(object sender, EventArgs e) { // Perform Delete Activity Logic if (activiteBindingSource.Count != 0) { var activityToRemove = activiteBindingSource.Current as Activite; using (ClubDbContext context = new ClubDbContext()) { var activityInDb = context.Activites .SingleOrDefault(a => a.CodeActivite == activityToRemove.CodeActivite); context.Adherents.SingleOrDefault(a => a.CodeAdh == currentUser.AdherentId) .PreferredActivities.Remove(activityInDb); context.SaveChanges(); } Activities_Load(sender, e); } else { MetroFramework.MetroMessageBox.Show(this, "Veuillez Selectionner une ligne dans le tableau ou bien " + "remplire votre liste des Activités préfférés si elle est vide!", "Données Non Valides", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// Implements Registration of user informations (suivent) / modifying registered user informations (modifier) private async void NextModifyBtn_Click(object sender, EventArgs e) { /* Perform add user registration to db */ // Get user data to a model Adherent newAdh = new Adherent { Nom = NameTB.Text, Prenom = PrenomTB.Text, Sexe = SexeCB.SelectedItem.ToString(), Cin = CinTB.Text, Tel = TelTB.Text, TelUrgence = TelUrgenceTB.Text, Adresse = AdresseTB.Text, Ville = VilleTB.Text, CNE = (CneTB.Text != "CNE Pour Bénificier d'une réduction étudiant") ? CneTB.Text : null }; // Instanciating validators RegistrationValidator validator = new RegistrationValidator(); ValidationResult results = await validator.ValidateAsync(newAdh); // User input data is not valid if (!results.IsValid) { // Display Errors to user foreach (ValidationFailure failure in results.Errors) { UserErrors.Add(failure.ErrorMessage); } MetroFramework.MetroMessageBox.Show(this, string.Join("\n", UserErrors), "Données Non Valides", MessageBoxButtons.OK, MessageBoxIcon.Error); // Clear errors for another use and quit UserErrors.Clear(); return; } // All is valid let's attach adherent informations to the user using (ClubDbContext _context = new ClubDbContext()) { var userInDb = await _context.Users.FirstOrDefaultAsync(u => u.Id == currentUser.Id); if (userInDb != null) { userInDb.Adherent = newAdh; } await _context.SaveChangesAsync(); userInDb.AdherentId = userInDb.Adherent.CodeAdh; await _context.SaveChangesAsync(); } // call the event to quit this shit OnSetRegistration(); }
public TournamentRegistrationModel(ClubDbContext context, IApi api, Services.IMailService mailService, ILogger <TournamentRegistrationModel> logger) { _clubDbContext = context; _api = api; _mailService = mailService; _logger = logger; TournamentPage = new TournamentPage(); Registration = new TournamentRegistration(); }
private void Profile_Load(object sender, EventArgs e) { formEnabled(false); using (ClubDbContext context = new ClubDbContext()) { adherentBindingSource.DataSource = context.Adherents .SingleOrDefault(a => a.CodeAdh == currentUser.AdherentId); } }
public static void SeedHostDb(ClubDbContext context) { context.SuppressAutoSetTenantId = true; // Host seed new InitialHostDbBuilder(context).Create(); // Default tenant seed (in host database). new DefaultTenantBuilder(context).Create(); new TenantRoleAndUserBuilder(context, 1).Create(); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email, StudentId = model.StudentId, DateJoined = DateTime.Now }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { Student student = new Student { StudentId = model.StudentId, FirstName = model.FirstName, LastName = model.LastName }; using (ClubDbContext ctx = new ClubDbContext()) { ctx.Students.Add(student); } using (ApplicationDbContext ctx = new ApplicationDbContext()) { UserManager <ApplicationUser> userManager = new UserManager <ApplicationUser>( new UserStore <ApplicationUser>(ctx)); UserManager.AddToRole(student.StudentId, "Student"); } await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public void SeedStudents(ApplicationDbContext current) { List <Student> selectedStudents = new List <Student>(); using (ClubDbContext ctx = new ClubDbContext()) { var randomStudentSet = ctx.Students .Select(s => new { s.StudentId, r = Guid.NewGuid() }); List <string> subset = randomStudentSet .OrderBy(s => s.r) .Select(s => s.StudentId).Take(10).ToList(); foreach (string s in subset) { selectedStudents.Add( ctx.Students.First(st => st.StudentId == s) ); } Club chosen = ctx.Clubs.First(); foreach (Student s in selectedStudents) { ctx.Members.AddOrUpdate(m => m.StudentId, new Member { ClubId = chosen.ClubId, StudentId = s.StudentId }); } ctx.SaveChanges(); } foreach (Student s in selectedStudents) { current.Users.AddOrUpdate(u => u.StudentId, new ApplicationUser { StudentId = s.StudentId, UserName = s.StudentId + "@mail.itsligo.ie", Email = s.StudentId + "@mail.itsligo.ie", EmailConfirmed = true, DateJoined = DateTime.Now, PasswordHash = new PasswordHasher().HashPassword("s" + s.StudentId + "$1"), SecurityStamp = Guid.NewGuid().ToString(), }); } current.SaveChanges(); }
private void adherents_Load(object sender, EventArgs e) { // disable form for input security control formEnabled(false); // Get all adherent from the db and bind them to the data source using (ClubDbContext context = new ClubDbContext()) { adherentBindingSource.DataSource = context.Adherents.ToList(); seanceBindingSource.DataSource = context.Seances.ToList(); } currentAdh = adherentBindingSource.Current as Adherent; currentSeance = seanceBindingSource.Current as Seance; }
/* * Open Close childs forms helpers */ // Update the current user if changed public void UpdateCurrentUser() { try { using (ClubDbContext context = new ClubDbContext()) { this.currentUser = context.Users.SingleOrDefault(u => u.Id == currentUser.Id); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
// Affect Seance to coach logic private void AffecterSeanceBtn_Click(object sender, EventArgs e) { if (currentSeance != null && currentCoach != null) { try { using (ClubDbContext context = new ClubDbContext()) { var coachInDb = context.Coaches .Include(c => c.Activites) .Include(c => c.Seances) .SingleOrDefault(c => c.CodeCoach == currentCoach.CodeCoach); var seanceInDb = context.Seances .Include(s => s.Coach) .Include(s => s.Activites) .Include(s => s.Salle) .SingleOrDefault(s => s.CodeSeance == currentSeance.CodeSeance); if (coachInDb != null && seanceInDb != null) { coachInDb.Seances.Add(seanceInDb); context.SaveChanges(); } MetroFramework.MetroMessageBox.Show(this, "La séance dont le code est " + seanceInDb.CodeSeance + " qui a comme horaire: " + seanceInDb.DebutSeance + " a bien été associée au coach: " + coachInDb.Nom + " " + coachInDb.Prenom + " !", "Séance afféctée avec succés", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox .Show(ex.Message); } } else { // show added message to display No Seance selected error MetroFramework.MetroMessageBox.Show(this, "Vous n'avez séléctionné aucunne séance ou bien" + "La base de donnée ne contiens aucunne séance !", "Pas de Seance selectionnées", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Activities_Load(object sender, EventArgs e) { formEnabled(false); // Bind the data source from db using (ClubDbContext context = new ClubDbContext()) { var currentUserPrefferedActivities = context.Adherents .Include(a => a.PreferredActivities) .SingleOrDefault(a => a.CodeAdh == currenUser.AdherentId) .PreferredActivities.ToList(); activiteBindingSource.DataSource = currentUserPrefferedActivities; } }
// checks if the current user already added this form informations private async void Registration_Load(object sender, EventArgs e) { using (ClubDbContext _context = new ClubDbContext()) { var userInDb = await _context.Users.Include(u => u.Adherent).SingleOrDefaultAsync(u => u.Id == currentUser.Id); if (userInDb != null) { if (userInDb.Adherent != null) { OnSetRegistration(); } } } }
// Perform dicipline affectation logic private void AffecterDicipline_Click(object sender, EventArgs e) { if (activitiesCB.SelectedItem.ToString() != "Choisir Votre Discipline" && activitiesCB.SelectedItem.ToString() != string.Empty) { var currentCoach = (coachBindingSource.Current != null) ? coachBindingSource.Current as Coach : null; if (currentCoach != null) { using (ClubDbContext context = new ClubDbContext()) { var coachToModify = context.Coaches .SingleOrDefault(c => c.CodeCoach == currentCoach.CodeCoach); if (coachToModify.Activites.Count <= 2) { var activityToAdd = context.Activites .SingleOrDefault(a => a.Nom == activitiesCB.SelectedItem.ToString()); coachToModify.Activites.Add(activityToAdd); context.SaveChanges(); MetroFramework.MetroMessageBox.Show(this, "La discipline " + activityToAdd.Nom + " a bien été afféctée " + "au coach " + coachToModify.Nom + " !", "Discipline affécté avec succès", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MetroFramework.MetroMessageBox.Show(this, "Désolé vous ne pouvez pas affecter plus de 2 disciplines " + "à un coach !", "Erreur d'affectation de discipline", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } // disable the label AffecterDicipline.Enabled = false; AffecterDicipline.ForeColor = Color.Gray; // set ddl to 0 activitiesCB.SelectedIndex = 0; }
// Delete Adherent private async void SupprimerBtn_Click(object sender, EventArgs e) { // Get current adherent Adherent adhToRemove = adherentBindingSource.Current as Adherent; // Get adherent to remove from db try { using (ClubDbContext context = new ClubDbContext()) { var userToDelete = context.Users .Include(u => u.Adherent) .SingleOrDefault(u => u.AdherentId == adhToRemove.CodeAdh); var correspondingAdherent = context.Adherents .Include(u => u.PreferredActivities) .Include(u => u.Seances) .SingleOrDefault(a => a.CodeAdh == adhToRemove.CodeAdh); var prefActivities = correspondingAdherent.PreferredActivities.ToList(); foreach (var act in prefActivities) { correspondingAdherent.PreferredActivities.Remove(act); } var seances = correspondingAdherent.Seances.ToList(); foreach (var seance in seances) { correspondingAdherent.Seances.Remove(seance); } context.Adherents.Remove(correspondingAdherent); context.SaveChanges(); context.Users.Remove(userToDelete); context.SaveChanges(); } adherents_Load(sender, e); } catch (ArgumentNullException ex) { MetroFramework.MetroMessageBox.Show(this, "Aucun adhérent n'est séléctionnée ou bien la" + " base de données est vide.", "Pas d'adhérent séléctionné", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void Subscribe_Load(object sender, EventArgs e) { // Set the price to user using (ClubDbContext context = new ClubDbContext()) { var adherent = context.Adherents .SingleOrDefault(a => a.CodeAdh == currentUser.AdherentId); var totalToPay = adherent.PreferredActivities .Sum(a => a.Prix); PriceTb.Text += (adherent.CNE == null || adherent.CNE == string.Empty) ? totalToPay.ToString() + " DH!" : Math.Truncate((decimal)0.8 * totalToPay).ToString() + " DH! " + "avec réduction étudiant (20%) !"; } }
private void ActivitiesCB_SelectedIndexChanged(object sender, EventArgs e) { if (ActivitiesCB.SelectedIndex == 0) { return; } using (ClubDbContext context = new ClubDbContext()) { coachs.Clear(); salles.Clear(); var selectedActivity = context.Activites .SingleOrDefault(a => a.Nom == ActivitiesCB.SelectedItem.ToString()); // Salle Binding var salleNameInDb = context.Salles .SingleOrDefault(s => s.CodeSalle == selectedActivity.SalleId); salles.Add("Choisir Votre Salle"); salles.Add(salleNameInDb.Discipline); // bind data to the cb collection of values SallesCB.DataSource = salles; // Coach Binding var activityInDb = context.Activites .SingleOrDefault(a => a.CodeActivite == selectedActivity.CodeActivite); coachs.Add("Choisir Votre Coach"); if (activityInDb.Coachs.Count != 0) { foreach (var coach in activityInDb.Coachs) { coachs.Add(coach.Nom); } } else { coachs.Add("Aucun cauch n'est enregistré avec cette discipline!"); } CoachsCB.DataSource = coachs; } SallesCB.SelectedIndex = 0; }
private void UnsubscribeBtn_Click(object sender, EventArgs e) { // Perform Unsubscribe Logic if (UnsubscribeTB.Text != string.Empty) { try { using (ClubDbContext context = new ClubDbContext()) { var userToDelete = context.Users .Include(u => u.Adherent) .SingleOrDefault(u => u.Id == currentUser.Id); var correspondingAdherent = context.Adherents .Include(u => u.PreferredActivities) .Include(u => u.Seances) .SingleOrDefault(u => u.CodeAdh == currentUser.AdherentId); var prefActivities = correspondingAdherent.PreferredActivities.ToList(); foreach (var act in prefActivities) { correspondingAdherent.PreferredActivities.Remove(act); } var seances = correspondingAdherent.Seances.ToList(); foreach (var seance in seances) { correspondingAdherent.Seances.Remove(seance); } context.Adherents.Remove(correspondingAdherent); context.Users.Remove(userToDelete); context.SaveChanges(); } Application.Restart(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void DeleteSeanceBtn_Click(object sender, EventArgs e) { // Perform Delete Logic var seanceToDelete = seanceBindingSource.Current as Seance; try { if (seanceToDelete != null) { using (ClubDbContext context = new ClubDbContext()) { var seanceInDb = context.Seances .Include(s => s.Activites) .Include(s => s.Adherents) .SingleOrDefault(s => s.CodeSeance == seanceToDelete.CodeSeance); var adherents = seanceInDb.Adherents.ToList(); var activites = seanceInDb.Activites.ToList(); foreach (var activity in activites) { seanceInDb.Activites.Remove(activity); } foreach (var adherent in adherents) { seanceInDb.Adherents.Remove(adherent); } context.Seances.Remove(seanceInDb); context.SaveChanges(); } Activities_Load(sender, e); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
// Implements Registration of user informations (suivent) / modifying registered user informations (modifier) private async void NextModifyBtn_Click(object sender, EventArgs e) { if (ModifyBtn.Text.Equals("Modifier")) { // Enable form to user formEnabled(true); // Change UI formColors(Color.WhiteSmoke); // Change button text ModifyBtn.Text = "Sauvegarder"; } else if (ModifyBtn.Text.Equals("Sauvegarder")) { /* Perform Modify Logic */ // Get current Adherent currentAdherent = adherentBindingSource.Current as Adherent; // Instanciating validators RegistrationValidator validator = new RegistrationValidator(); ValidationResult results = await validator.ValidateAsync(currentAdherent); // User input data is not valid if (!results.IsValid) { // Display Errors to user foreach (ValidationFailure failure in results.Errors) { UserErrors.Add(failure.ErrorMessage); } MetroFramework.MetroMessageBox.Show(this, string.Join("\n", UserErrors), "Données Non Valides", MessageBoxButtons.OK, MessageBoxIcon.Error); // Clear errors for another use and quit UserErrors.Clear(); return; } // Get adherent from database using (ClubDbContext context = new ClubDbContext()) { var adherentInDB = context.Adherents .SingleOrDefault(a => a.CodeAdh == currentAdherent.CodeAdh); adherentInDB.Nom = currentAdherent.Nom; adherentInDB.Prenom = currentAdherent.Prenom; adherentInDB.Sexe = currentAdherent.Sexe; adherentInDB.Cin = currentAdherent.Cin; adherentInDB.Tel = currentAdherent.Tel; adherentInDB.TelUrgence = currentAdherent.TelUrgence; adherentInDB.Adresse = currentAdherent.Adresse; adherentInDB.Ville = currentAdherent.Ville; adherentInDB.CNE = currentAdherent.CNE; await context.SaveChangesAsync(); } // Refresh dataGrid Profile_Load(sender, e); // Disable form to user formEnabled(false); // Change Ui formColors(Color.FromArgb(172, 126, 241)); // Change button text ModifyBtn.Text = "Modifier"; } }
public DefaultSettingsCreator(ClubDbContext context) { _context = context; }
// Add New Coach to db private async void NextModifyBtn_Click(object sender, EventArgs e) { if (AjouterBtn.Text.Equals("Ajouter")) { // Enable form to user formEnabled(true); // Change UI formColors(Color.WhiteSmoke); // default text formTbInitializeText(); // Change button text AjouterBtn.Text = "Sauvegarder"; // add new field coachBindingSource.Add(new Coach()); coachBindingSource.MoveLast(); } else if (AjouterBtn.Text.Equals("Sauvegarder")) { /* Perform Add Logic */ // get user input Coach newCoach = coachBindingSource.Current as Coach; // Instanciating validators CoachsValidator validator = new CoachsValidator(); ValidationResult results = await validator.ValidateAsync(newCoach); // User input data is not valid if (!results.IsValid) { // Display Errors to user foreach (ValidationFailure failure in results.Errors) { UserErrors.Add(failure.ErrorMessage); } MetroFramework.MetroMessageBox.Show(this, string.Join("\n", UserErrors), "Données Non Valides", MessageBoxButtons.OK, MessageBoxIcon.Error); // Clear errors for another use and quit UserErrors.Clear(); return; } // add new coach in db using (ClubDbContext context = new ClubDbContext()) { context.Coaches.Add(newCoach); await context.SaveChangesAsync(); } // refresh Coachs_Load(sender, e); // Disable form to user formEnabled(false); // Change Ui formColors(Color.FromArgb(253, 138, 114)); // Change button text AjouterBtn.Text = "Ajouter"; } }
// Connect user private async void LoginBtn_Click(object sender, EventArgs e) { // Get user data to a model User UserData = new User { Email = EmailTB.Text, Password = PasswordTB.Text }; // Validate Model IdentificationValidator validator = new IdentificationValidator(); ValidationResult result = await validator.ValidateAsync(UserData); if (!result.IsValid) { // Display Errors to user foreach (ValidationFailure failure in result.Errors) { UserErrors.Add(failure.ErrorMessage); } MetroFramework.MetroMessageBox.Show(this, string.Join("\n", UserErrors), "Données Non Valides", MessageBoxButtons.OK, MessageBoxIcon.Error, 400); // Clear errors for another use and quit UserErrors.Clear(); return; } // All data is valid let's check database for the user using (ClubDbContext _context = new ClubDbContext()) { // Get user from db with email try { User userInDb = await _context.Users.SingleOrDefaultAsync(u => u.Email == UserData.Email); // Verify if the email exists and if the password matches the hashed one in Db if (userInDb != null && Crypto.VerifyHashedPassword(userInDb.Password, UserData.Password)) { // Password and email matches let's notify the main form (user connected) OnUserLoggedIn(userInDb); } else { // User data incorrect, display error message MetroFramework.MetroMessageBox.Show(this, "L'email que vous avez rentrez et/ou le mot de passe" + "ne sont pas valide, Veuillez Réssayer!", "Données non valides", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public DefaultTenantBuilder(ClubDbContext context) { _context = context; }
// Check Client Subscription to disable free navigation and go to inscription private void ClientMenu_Load(object sender, EventArgs e) { using (ClubDbContext _context = new ClubDbContext()) { } }