public async Task CreateRegisterInfo(RegisterInfo newRegInfo, string Password) { var isExistPremises = await _premisesRepos.FindByName(newRegInfo.PremisesName); var isExistUser = await _userRepository.FindByUsername(newRegInfo.Username); if (isExistPremises != null) { throw new DuplicatedPremisesNameException("Tên cơ sở đã tồn tại"); } else if (isExistUser != null) { throw new DuplicatedUsernameException("Tài khoản đã tồn tại"); } else { //tạo premises mới var newPremises = new Premises(); newPremises.Name = newRegInfo.PremisesName; newPremises.Address = newRegInfo.PremisesAddress; newPremises.PremisesType = _premisesTypeRepos.GetById(newRegInfo.PremisesTypeId); //tạo user mới var user = new User(); var hashedPassword = PasswordHasher.GetHashPassword(Password); //Get hashedpassword var role = _roleRepos.GetById(2); //Get manager Role user.Password = hashedPassword.HashedPassword; user.Fullname = newRegInfo.Fullname; user.Salt = hashedPassword.Salt; user.Role = role; user.Username = newRegInfo.Username; user.Email = newRegInfo.Email; user.Image = "/app-assets/images/avatar.jpg"; user.Premises = newPremises; //Code for activation string activateCode = Util.GeneratePassword(new Models.PasswordOptions() { RequireDigit = true, RequiredLength = 12, RequireLowercase = true, RequireNonAlphanumeric = false, RequireUppercase = true }); user.ActivationCode = activateCode; user.IsConfirmEmail = false; _userRepository.Insert(user, true); //tạo register info /*newRegInfo.RegisterId = 0; * newRegInfo.IsConfirm = null; * _registerRepos.Insert(newRegInfo, true);*/ //Send email await _mailSender.SendEmailAsync(user.Email, "[TFS] Kích Hoạt tài khoản", "Vui lòng nhấn vào để kích hoạt tài khoản \n" + " https://localhost:5000/kich-hoat-tai-khoan/?ActivationCode=" + activateCode); } }
private void Edit_Click(object sender, RoutedEventArgs e) { Premises premises = premisesList.SelectedItem as Premises; premisesAdd p = new premisesAdd(premises); p.ShowDialog(); }
public async Task ActivateAccount(string activateCode) { User user; user = await _userRepos.FindAsync(u => u.ActivationCode == activateCode); if (user == null) { throw new NotFoundException(msg: "Mã kích hoạt không chính xác"); } user.IsConfirmEmail = true; user.IsActive = true; var activeCode = Util.GeneratePassword(new Models.PasswordOptions() { RequireDigit = true, RequiredLength = 6, RequireLowercase = true, RequireNonAlphanumeric = false, RequireUppercase = true }); user.ActivationCode = activeCode; Premises premises = await _premesisRepos.FindAsync(x => x.PremisesId == user.PremisesId); premises.IsActive = true; await _userRepos.UpdateAsync(user); await _premesisRepos.UpdateAsync(premises); }
private void Button_Click(object sender, RoutedEventArgs e) { Premises premises = premisesList.SelectedItem as Premises; reportView report = new reportView(premises.id); report.Title = "Отчет: " + premises.name; report.Show(); }
private void Delete_Click(object sender, RoutedEventArgs e) { Premises premises = premisesList.SelectedItem as Premises; Helper.Connection.Premises.Remove(premises); Helper.Connection.SaveChanges(); premisesList.ItemsSource = Helper.Connection.Premises.ToList(); }
public Definition EraseNamespaces() { return(new Definition { Name = Name, Bound = Bound, Premises = Premises.Select(x => x.EraseNamespaces()), Conclusion = Conclusion.EraseNamespaces() }); }
private void ControlPoint_Click(object sender, RoutedEventArgs e) { //BlurEffect blurEffect = new BlurEffect(); //this.RegisterName("blurEffect", blurEffect); //blurEffect.Radius = 10.0; //content.Effect = blurEffect; Premises premises = premisesList.SelectedItem as Premises; ControlPointWindow controlPointWindow = new ControlPointWindow(premises.id, premises.name); controlPointWindow.Show(); }
public premisesAdd(Premises p) { InitializeComponent(); if (p.id != 0) { actionButton.Content = "Сохранить"; this.Title = "Изменить"; } myPremises = p; premisesName.Text = myPremises.name; premisesDescription.Text = myPremises.description; this.Width = 500; this.Height = 200; }
public Definition Replace(string from, string to) { if (from == to) { return(this); } Debug.WriteLine(from + " --> " + to); return(new Definition { Name = Name, Bound = Bound, Premises = Premises.Select(x => x.Replace(from, to)), Conclusion = Conclusion.Replace(from, to) }); }
public async Task <bool> Register(User newUser, Premises newPremises) { var hashedPassword = PasswordHasher.GetHashPassword(newUser.Password); var user = await _userRepos.FindByUsername(newUser.Username); var mail = await _userRepos.FindAllAsync(x => x.Email == newUser.Email); var activeCode = Util.GeneratePassword(new Models.PasswordOptions() { RequireDigit = true, RequiredLength = 6, RequireLowercase = true, RequireNonAlphanumeric = false, RequireUppercase = true }); if (user != null) { throw new DuplicatedUsernameException(msg: MessageConstant.DUPLICATED_USERNAME); } //if (mail.Count > 0) //{ // throw new DuplicateEmailException(msg: MessageConstant.DUPLICATED_EMAIL); //} await _premesisRepos.InsertAsync(newPremises); newPremises.IsActive = false; await _premesisRepos.UpdateAsync(newPremises); newUser.Password = hashedPassword.HashedPassword; newUser.Salt = hashedPassword.Salt; newUser.ActivationCode = activeCode; newUser.RoleId = 2; newUser.PremisesId = newPremises.PremisesId; newUser.IsConfirmEmail = false; await _userRepos.InsertAsync(newUser); newUser.IsActive = false; await _userRepos.UpdateAsync(newUser); if (newUser.UserId > 0) { return(true); } return(false); }
public PremisesDialog() { InitializeComponent(); premises = new Premises(); tbId.DataContext = premises; tbName.DataContext = premises; tbDescription.DataContext = premises; cbHandicapable.DataContext = premises; cbReservations.DataContext = premises; cbSmoking.DataContext = premises; cbAlcohol.ItemsSource = Globals.AlcoholServings; cbAlcohol.DataContext = premises; cbPrice.ItemsSource = Globals.PriceCategories; cbPrice.DataContext = premises; tbCapacity.DataContext = premises; dpOpeningDate.DataContext = premises; cbType.ItemsSource = Globals.Types; }
public string ToLatex() { return($"\\frac{{{Premises.Aggregate("", (a,b)=>$"{a},{b.ToLatex()}").Substring(1)}}}{{{Conclusion.ToLatex()}}}"); }