public ActionResult RegisterOne(UserSerializer user) { // Parsing de la date string[] tempDate = user.birthDate.Split('/'); bool userExist = userRepository.MailExist(user.mail); // On test si le mail existe déjà dans la base if (userExist) { System.Diagnostics.Debug.WriteLine("User déjà existant"); return View(); } else { Domaine.Common.User savingUser = new User(); savingUser.Name = user.name; savingUser.FirstName = user.firstName; savingUser.Mail = user.mail; savingUser.Salt = BCrypt.Net.BCrypt.GenerateSalt(); savingUser.PassWord = BCrypt.Net.BCrypt.HashPassword(user.password, savingUser.Salt); savingUser.IncriptionDate = DateTime.Now; savingUser.Birthday = new DateTime(Convert.ToInt32(tempDate[2]), Convert.ToInt32(tempDate[1]), Convert.ToInt32(tempDate[0])); if (user.gender.Equals("true")) { savingUser.Gender = true; } else { savingUser.Gender = false; } bool userCreationSucceed = userRepository.Save(savingUser); // On test la réussite de la création du User if (userCreationSucceed) { System.Diagnostics.Debug.WriteLine("Création réussie !"); } else { System.Diagnostics.Debug.WriteLine("Echec de la création!"); } } return View(); }
public bool Save(User _user) { db.Users.Add(_user); db.SaveChanges(); return true; }
public void Update(User _user) { db.SaveChanges(); }
public void Delete(User _cours) { db.Users.Remove(_cours); db.SaveChanges(); }