protected override async Task ProcessAsync() { Alert.ComponentRemove(); if (Button.IsClick) { var appMain = this.ComponentOwner <AppMain>(); // Insert LoginUser var userLocal = Grid.RowList.Single(); string password = userLocal.PasswordHash; // User entered password string passwordConfirm = userLocal.PasswordSalt; // User entered password confirmation if (password != passwordConfirm) { Alert = new Alert(appMain, "Password and password confirmation do not match!", AlertEnum.Warning); } else { if (password.Length <= 3) { Alert = new Alert(appMain, "Password too short!", AlertEnum.Warning); } else { UtilFramework.PasswordHash(password, out var passwordHash, out var passwordSalt); var user = new LoginUser { Name = userLocal.Name, NameFirst = userLocal.NameFirst, NameLast = userLocal.NameLast, Email = userLocal.Email, PasswordHash = passwordHash, PasswordSalt = passwordSalt, IsDelete = false }; await Data.InsertAsync(user); Alert = new Alert(appMain, "Sign up successfull! Email has been sent for confirmation! Go to <a href='/signin/'>Sign in</a>", AlertEnum.Success); // InsertUserRole (assign Guest and Customer role) int loginRoleid = await LoginRoleIntegrateApp.IdEnum.Guest.Id(); LoginUserRole userRole = new LoginUserRole { LoginUserId = user.Id, LoginRoleId = loginRoleid, IsActive = true }; await Data.InsertAsync(userRole); loginRoleid = await LoginRoleIntegrateApp.IdEnum.Customer.Id(); userRole = new LoginUserRole { LoginUserId = user.Id, LoginRoleId = loginRoleid, IsActive = true }; await Data.InsertAsync(userRole); } } } }
protected override async Task UpdateAsync(UpdateArgs args, UpdateResult result) { var navigateLoginRole = new LoginUserRole { LoginUserId = args.Row.LoginUserId, LoginRoleId = args.Row.LoginRoleId, IsActive = args.Row.IsActive }; if (args.Row.LoginUserRoleId != null) { navigateLoginRole.Id = args.Row.LoginUserRoleId.Value; await Data.UpdateAsync(navigateLoginRole); } else { await Data.InsertAsync(navigateLoginRole); } result.IsHandled = true; }
public App() { AppBkBrush = Xceed.Wpf.Themes.Office2007.Office2007BlueResources.ApplicationBackgroundBrush; Systeminfo = new SubsystemManager(); LoginRole = new LoginUserRole(); string path = System.Reflection.Assembly.GetExecutingAssembly().Location; Environment.CurrentDirectory = System.IO.Path.GetDirectoryName(path); AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs ex) { if (ex == null) { return; } MessageBox.Show(ex.ExceptionObject.ToString()); Environment.Exit(1); }; }