public ActionResult UserInformation(Guid UserId) { var model = UserProcessor.GetUserToModel(UserId); ViewBag.Message = $"User: {model.Name}"; return(View(model)); }
public ActionResult Index() { // Make sure the user is logged in and that they have permission if (!IsUserLoggedIn) { return(RedirectToLogin()); } if (!UserHasPermission(PermissionName.User)) { return(RedirectToPermissionDenied()); } // Set the page message ViewBag.Message = "Users List"; // Get all users from the database var userModels = UserProcessor.SelectUsers(); // Change the format of the user list List <User> users = new List <User>( ); foreach (var u in userModels) { users.Add(new User(u)); } // Return the view, with the list of users return(View(users)); }
//public virtual List<User> AvailableEnrollments { get; set; } // Add list for Available Enrollments public List <Enrollment> GetAvailableEnrollments(int unitOfferingId) { var enrollmentData = EnrollmentProcessor.LoadEnrollmentsForUnitOffering(unitOfferingId); var enrollments = new List <Enrollment>( ); foreach (var row in enrollmentData) { var rowData = UserProcessor.SelectUserForUserId(row.UserId); var enrollment = new Enrollment { EnrollmentId = row.EnrollmentId, UserId = row.UserId, Username = rowData.Username, //FirstName = rowData.FirstName, //LastName = rowData.LastName, //EmailAddress = rowData.Email, //PhoneNumber = rowData.PhoneNo, //Password = rowData.Password }; enrollments.Add(enrollment); } return(enrollments); }
private void button1_Click(object sender, EventArgs e) { InitializeListView(); user = new UserProcessor(); Collection <UserModel> users = UserProcessor.GetAllResults(); if (users == null) { return; } foreach (UserModel user in users) { ListViewItem item = new ListViewItem(user.Id.ToString()); item.SubItems.Add(user.Email); item.SubItems.Add(user.Name); item.SubItems.Add(user.Surname); item.SubItems.Add(user.Phone); item.SubItems.Add(user.Adress); item.SubItems.Add(user.Birthday); item.SubItems.Add(user.Verified.ToString()); item.SubItems.Add(user.Password); item.SubItems.Add(user.UserType); listView1.Items.Add(item); } }
private async Task <bool> SignIn() { if (IsInternet()) { //check if fields are completed if (String.IsNullOrWhiteSpace(Username) || String.IsNullOrWhiteSpace(Password)) { await DisplayError(ErrorMsg.CompleteAllFieldsError); } else { await PageService.PushPopupAsync(new WaitForActionView()); //create auth password string authPassword = VaultManager.CreateAuthPassword(Username, Password); Models.TaskStatus statusLogin = await UserProcessor.LogIn(ApiHelper.ApiClient, Username, authPassword); if (!statusLogin.IsError) { return(true); } else { await PageService.PopPopupAsync(); await DisplayError(statusLogin.Message); } } } return(false); }
public ActionResult Account() { var data = UserProcessor.LoadUser(User.Identity.GetUserId()); GameUser user = new GameUser { FirstName = data.Fname, LastName = data.Lname, Age = data.Age, Balance = data.Balance }; user.GamesBought = PurchaseProcessor.GetGamesBought(User.Identity.GetUserId()); user.GamesSold = PurchaseProcessor.GetGamesSold(User.Identity.GetUserId()); var list = GameProcessor.GetGamesOnSale(User.Identity.GetUserId()); user.GamesOnSale = new List <Game>(); foreach (var row in list) { user.GamesOnSale.Add(new Game { Name = row.Name, CreatedBy = row.CreatedBy, Year = row.Year, GameConsole = row.Console }); } return(View(user)); }
public void TestInsertApiKey() { bool test1 = false; bool test2 = true; bool noExceptionWasThrown = true; string apikey = ""; try { UserProcessor up = new UserProcessor(); up.InsertNewUser("name", "*****@*****.**", "password"); test1 = up.InsertApiKey("*****@*****.**", "key"); test2 = up.InsertApiKey("Non existing email address", "key"); User user = up.LogInUser("*****@*****.**", "password"); apikey = user.ApiKey; }catch (Exception) { noExceptionWasThrown = false; }finally { //CleanUp UserAccess userAccess = new UserAccess(); userAccess.DeleteByName("name"); } Assert.IsTrue(test1); Assert.IsFalse(test2); Assert.AreEqual("key", apikey); Assert.IsTrue(noExceptionWasThrown); }
static void loop_01() { Parallel.For(1, 100, i => { using (var context = new EfeObjectContext(connectionString, DbOptions.UseSqlServer)) { context.ModelBuild(); using (var readonlyContext = new EfeReadonlyDbContext(readonlyConnectionString, DbOptions.UseSqlServer)) { readonlyContext.ModelBuild(); IRepository <User> repository = new EfeRepository <User>(context); IReadonlyRepository <User> readRepository = new EfeReadonlyRepository <User>(readonlyContext); var userService = new UserService(repository, readRepository); var userProcess = new UserProcessor(userService); userProcess.Add(); userProcess.Search(); repository.Dispose(); readRepository.Dispose(); } } }); // 查询 SqlServer 中的链接数 //SELECT * FROM sys.dm_exec_sessions WHERE host_name IS NOT NULL AND host_name = 'Dell_2039100' ORDER BY host_name }
private void hlbtnEdit_Click(object sender, RoutedEventArgs e) { if (!AuthMgr.HasFunctionPoint(AuthKeyConst.Vendor_UserMgmt_Edit)) { Window.Alert(ResVendorInfo.Msg_HasNoRight); return; } DynamicXml selectedModel = this.dataGrid.SelectedItem as DynamicXml; if (null != selectedModel) { UserProcessor newRequestCtrl = new UserProcessor((int)selectedModel["SysNo"]); newRequestCtrl.Dialog = Window.ShowDialog( ResVendorInfo.Header_EditVendorUser , newRequestCtrl , (s, args) => { if (args.DialogResult == DialogResultType.OK) { dataGrid.Bind(); } } , new Size(850, 550) ); } }
public List <User> GetStudents( ) { var studentData = UserProcessor.SelectStudents( ); Users = new List <User>( ); foreach (var row in studentData) { var rowData = UserProcessor.SelectUserForUserId(row.UserId); var user = new User { UserId = rowData.UserId, Username = rowData.Username, FirstName = rowData.FirstName, LastName = rowData.LastName, EmailAddress = rowData.Email, PhoneNumber = rowData.PhoneNo, Password = rowData.Password }; Users.Add(user); } return(Users); }
private Guid GetUserId(string userName) { User user = BusinessLogicConverter.ToUser(userName); UserProcessor.LogIn(user); return(user.Id); }
private async void register_btn_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { if (username_txt.Text != "" && password_txt.Text != "" && device_ip_txt.Text != "") { UserModel.Name = username_txt.Text; userModel.Password = password_txt.Text; UserModel.DeviceIp = device_ip_txt.Text; string[] splitValues = UserModel.DeviceIp.Split('.'); if (splitValues.Length != 4) { error_lbl.Text = "please enter a valid ip"; error_lbl.Foreground = new SolidColorBrush(Colors.Red); } else { string returnMsg = await UserProcessor.Register(userModel); if (returnMsg != "") { error_lbl.Text = returnMsg; } else { error_lbl.Text = "Error trying to register"; error_lbl.Foreground = new SolidColorBrush(Colors.Red); } } } else { error_lbl.Text = "Please complete all the information"; error_lbl.Foreground = new SolidColorBrush(Colors.Red); } }
static void Main(string[] args) { var user = new User("Filip Ekberg", "870101XXXX", new RegionInfo("SE"), new DateTimeOffset(1987, 01, 29, 00, 00, 00, TimeSpan.FromHours(2))); Console.WriteLine(user.Age); var processor = new UserProcessor(); var ressult = processor.Register(user); Console.WriteLine(ressult); //RegionInfo ro = new RegionInfo("RO"); //Type t = typeof(RegionInfo); //PropertyInfo[] listprops = t.GetProperties(); //foreach (PropertyInfo item in listprops) //{ // Console.WriteLine($"{item.Name}, {item.GetGetMethod()?.Invoke(ro, null)}"); //} }
private async void UserRegisterAsync() { ComboBoxItem typeItem = (ComboBoxItem)CBUserType.SelectedItem; string type = typeItem.Content.ToString(); int userType; if (type == T1.Content.ToString()) //Local { userType = 1; } else //foreign { userType = 2; } UserProcessor processor = new UserProcessor(); AuthResponseModel response = new AuthResponseModel(); response = await processor.RegisterAsync(Username1.Text, Password1.Text, userType); if (response.Response.Equals(200)) { GridLogin.Visibility = Visibility.Visible; GridRegister.Visibility = Visibility.Hidden; MessageBox.Show("Account created successfully! \n If registed as foreign student, you'll have to wait for Librarian's approval."); } else { MessageBox.Show(response.Info); } }
public void TestUserCRUD() { IUser user = CreateUser(); UserProcessor up = new UserProcessor(user); var save = up.Create().Result; Assert.IsTrue(save != null && save.Data != null && save.Data.Id != Guid.Empty, "User save failed."); var one = up.FetchById().Result; one.Data.Password = "******"; Assert.IsTrue(one != null && JsonConvert.SerializeObject(one, Formatting.None).Equals(JsonConvert.SerializeObject(save, Formatting.None)), "User fetch failed."); var loggedIn = up.Login().Result; Assert.IsTrue(loggedIn != null && loggedIn.Data != Guid.Empty, "User login failed."); var delete = up.Delete().Result; one = up.FetchById().Result; Assert.IsTrue(one.Data == null, "User delete failed."); var tp = new TokenProcessor(loggedIn.Data); int result = tp.Delete().Result; var t = tp.FetchById().Result; Assert.IsTrue(t.Data == null, "Token delete failed."); }
public ActionResult EditUser(int userId) { if (IsActiveSession()) { var data = UserProcessor.GetUser(userId); UserModel model = new UserModel { Id = data.Id, FirstName = data.FirstName, LastName = data.LastName, CompanyName = data.CompanyName, TaxId = data.TaxId, TobaccoLicense = data.TobaccoLicense, EmailAddress = data.EmailAddress, ConfirmEmail = data.EmailAddress, Password = data.Password, ConfirmPassword = data.Password, Address1 = data.Address1, Address2 = data.Address2, City = data.City, State = data.State, Zip = data.Zip, IsActive = data.IsActive }; return(View(model)); } return(RedirectToAction("Login", "Login", null)); }
public void TestEventCRUD() { IEvent e = CreateEvent(EventType.Wedding); var ep = new EventProcessor(e); var save = ep.Create().Result; Assert.IsTrue(save.Data != null && save.Data.Id != Guid.Empty, "Event save failed."); var one = ep.FetchById().Result; Assert.IsTrue(one.Data != null, "Event fetch failed."); var delete = ep.Delete().Result; one = ep.FetchById().Result; Assert.IsTrue(one.Data == null, "Event delete failed."); var vp = new VendorProcessor(e.Arrangements[0].Vendor.Id); var d = vp.Delete().Result; var o = vp.FetchById().Result; Assert.IsTrue(o.Data == null, "Vendor delete failed."); var uHelper = new UserProcessor(e.Arrangements[0].Vendor.Id); var uOne = uHelper.FetchById().Result; Assert.IsTrue(uOne.Data == null, "User not deleted from vendor delete."); }
public ActionResult ViewUsers() { if (IsActiveSession()) { var data = UserProcessor.LoadUsers(); List <UserModel> users = new List <UserModel>(); foreach (var row in data) { users.Add(new UserModel { Id = row.Id, FirstName = row.FirstName, LastName = row.LastName, CompanyName = row.CompanyName, TaxId = row.TaxId, TobaccoLicense = row.TobaccoLicense, EmailAddress = row.EmailAddress, Password = row.Password, Address1 = row.Address1, Address2 = row.Address2, City = row.City, State = row.State, Zip = row.Zip, IsActive = row.IsActive }); } return(View(users)); } return(RedirectToAction("Login", "Login", null)); }
public void TestLogIn() { string user1Name = ""; User user2 = null; User user3 = null; User user4 = null; bool noExceptionWasThrown = true; try { UserProcessor up = new UserProcessor(); up.InsertNewUser("name", "*****@*****.**", "password"); up.InsertNewUser("other name", "*****@*****.**", "password"); User user1 = up.LogInUser("name", "password"); user2 = up.LogInUser("other name", "password"); user3 = up.LogInUser("name", "wrong password"); user4 = up.LogInUser("name", "Password"); user1Name = user1.UserName; }catch (Exception) { noExceptionWasThrown = false; }finally { //CleanUp UserAccess userAccess = new UserAccess(); userAccess.DeleteByName("name"); userAccess.DeleteByName("other name"); } Assert.AreEqual("name", user1Name); Assert.IsNull(user2); Assert.IsNull(user3); Assert.IsNull(user4); Assert.IsTrue(noExceptionWasThrown); }
// Fill List Boxes private async void FillUserListBox() { lstUsers.Items.Clear(); users = await UserProcessor.GetUsers(currentUser.Token); foreach (UserModel m in users) { if (txtSort.Text == "") { lstUsers.Items.Add(m); } else { try { if (m.Lastname != null && m.Lastname.ToUpper() == txtSort.Text.ToUpper()) { lstUsers.Items.Add(m); } } catch (Exception ex) { MessageBox.Show("User with last name of " + txtSort.Text + " does not exist." + ex); } } } }
public void TestGetUserByEmailOrUserName() { User user2 = null; string user1name = ""; User user4 = null; string user3name = ""; bool noExceptionWasThrown = true; try { UserProcessor up = new UserProcessor(); up.InsertNewUser("name", "*****@*****.**", "password"); User user1 = up.GetUserByEmail("*****@*****.**"); user2 = up.GetUserByEmail("asd"); user1name = user1.UserName; User user3 = up.GetUserByUsername("name"); user4 = up.GetUserByUsername("asd"); user3name = user3.UserName; }catch (Exception) { noExceptionWasThrown = false; }finally { //CleanUp UserAccess userAccess = new UserAccess(); userAccess.DeleteByName("name"); } Assert.AreEqual("name", user1name); Assert.IsNull(user2); Assert.AreEqual("name", user3name); Assert.IsNull(user4); Assert.IsTrue(noExceptionWasThrown); }
/// <summary> /// Help register single-interest user processor. /// </summary> /// <param name="processor"> the processor need to be registered </param> /// <param name="userProcessors"> the map of user processors </param> public static void registerUserProcessor(UserProcessor processor, ConcurrentDictionary <Type, UserProcessor> userProcessors) { if (null == processor) { throw new RuntimeException("User processor should not be null!"); } if (processor is MultiInterestUserProcessor) { registerUserProcessor((MultiInterestUserProcessor)processor, userProcessors); } else { if (processor.interest() == null) { throw new RuntimeException("Processor interest should not be blank!"); } if (userProcessors.ContainsKey(processor.interest())) { string errMsg = "Processor with interest key [" + processor.interest() + "] has already been registered to rpc server, can not register again!"; throw new RuntimeException(errMsg); } else { userProcessors.TryAdd(processor.interest(), processor); } } }
private async Task <bool> Register() { if (IsInternet()) { //check if all fields are completed if (String.IsNullOrWhiteSpace(Username) || String.IsNullOrWhiteSpace(Password) || String.IsNullOrWhiteSpace(ConfirmPass)) { await DisplayError(ErrorMsg.CompleteAllFieldsError); } else { //verify status of fields Models.TaskStatus emailStatus = FieldsHelper.VerifyEmail(Username); if (!emailStatus.IsError) { Models.TaskStatus passwordStatus = FieldsHelper.VerifyPassword(Password); if (!passwordStatus.IsError) { if (ConfirmPass == Password) { if (!Password.ToLower().Contains(Username.ToLower())) { await PageService.PushPopupAsync(new WaitForActionView()); string authPassword = VaultManager.CreateAuthPassword(Username, Password); Models.TaskStatus statusRegister = await UserProcessor.Register(ApiHelper.ApiClient, Username, authPassword, authPassword); if (!statusRegister.IsError) { return(true); } else { await PageService.PopPopupAsync(); await DisplayError(statusRegister.Message); } } else { await DisplayError("Your email can't be in your password!"); } } else { await DisplayError("Your Confirm Password and your Password are not the same!"); } } else { await DisplayError(passwordStatus.Message); } } else { await DisplayError(emailStatus.Message); } } } return(false); }
public ActionResult SignUp(UserModel user) { // We need to remove any Username already used alerts if (Session["Username already used"] != null) { Session.Remove("Username already used"); } if (ModelState.IsValid) { // we need to check if the UserId is distinct if (UserProcessor.CheckUsername(user.Username)) { // If the username is already used by another account, we'll need to reload the page with a warning Session.Add("Username already used", true); return(View()); } UserProcessor.CreateUser(user.Username); if (Session["User"] == null) { Session.Add("User", UserProcessor.getUserId(user.Username)); } else { Session["User"] = UserProcessor.getUserId(user.Username); } return(RedirectToAction("Languages", "Language")); } return(View()); }
public void Show() { var user = new User() { Name = "Eleven", Password = "******" }; { var processor = new UserProcessor(); processor.RegUser(user); Console.WriteLine("*********************"); } { IUnityContainer container = new UnityContainer(); //声明一个容器 container.RegisterType <IUserProcessor, UserProcessor>(); //声明UnityContainer并注册IUserProcessor var processor = container.Resolve <IUserProcessor>(); processor.RegUser(user); //没有AOP的,可在此打个断点F11进入 //配置AOP,固定套路 container.AddNewExtension <Interception>() .Configure <Interception>() .SetInterceptorFor <IUserProcessor>(new InterfaceInterceptor()); var userprocessor = container.Resolve <IUserProcessor>(); //重新实例化 Console.WriteLine("********************"); userprocessor.RegUser(user); //有AOP的,可在此打个断点F11进入 userprocessor.GetUser(user); //有AOP的,可在此打个断点F11进入 } }
public ActionResult LoginUser(UserModel user) { // We need to remove any invalid username alerts if (Session["Invalid Username"] != null) { Session.Remove("Invalid Username"); } // We also need to remove any "Please Login" alerts if (Session["No User"] != null) { Session.Remove("No User"); } // we need to check if the UserId is in the database if (UserProcessor.CheckUsername(user.Username)) { if (Session["User"] == null) { Session.Add("User", UserProcessor.getUserId(user.Username)); } else { Session["User"] = UserProcessor.getUserId(user.Username); } return(RedirectToAction("Languages", "Language")); } // the username is not in the database, so we need to return the login page with the invalid username alert Session.Add("Invalid Username", true); return(View("Login")); }
public void RunMain(string messageBody) { if (messageBody.StartsWith("Start")) { gitProcessor.GitHubArchiveParser(Convert.ToDateTime(messageBody.Split(';')[1]), Convert.ToInt32(messageBody.Split(';')[2])); } else if (messageBody.StartsWith("PullRequest")) { PullRequestProcessor pulls = new PullRequestProcessor(messageBody); pulls.GetContent(); } else if (messageBody.StartsWith("Commit")) { CommitProcessor commits = new CommitProcessor(messageBody); commits.GetContent(); } else if (messageBody.StartsWith("Issue")) { IssueProcessor issues = new IssueProcessor(messageBody); issues.GetContent(); } else if (messageBody.StartsWith("User")) { UserProcessor users = new UserProcessor(messageBody); users.GetContent(); } else if (messageBody.StartsWith("Repository")) { RepositoryProcessor repositorys = new RepositoryProcessor(messageBody); repositorys.GetContent(); } }
//Go to the view users page public ActionResult ViewUsers() { //alter title ViewBag.Message = "User List"; //load users from database into a var using sql var data = UserProcessor.LoadUsers(); //instantiate list to hold user data List <UserModel> users = new List <UserModel>(); //add user models to the list for each user in the data foreach (var row in data) { users.Add(new UserModel { Id = row.Id, UserName = row.UserName, Email = row.Email, UserId = row.Id, RoleId = row.RoleId }); } //show the ViewUsers view populated with the list return(View(users)); }
public ActionResult MyProfile() { ViewBag.Message = "My Profile"; var data = UserProcessor.LoadUsers(); List <AccountModel> users = new List <AccountModel>(); foreach (var row in data) { users.Add(new AccountModel { FirstName = row.FirstName, LastName = row.LastName, PhoneNumber = row.PhoneNumber, StreetAddress = row.Address, City = row.City, State = row.State, Zip = row.Zip, Email = row.Email, Password = row.Password }); } return(View(users)); }
public bool SendEmail(Guid userId, string subject, string emailBody) { try { var userModel = UserProcessor.GetUserToModel(userId); string senderEmail = System.Configuration.ConfigurationManager.AppSettings["SenderEmail"].ToString(); string senderPassword = System.Configuration.ConfigurationManager.AppSettings["SenderPassword"].ToString(); SmtpClient client = new SmtpClient("smtp.gmail.com", 587); // Set encrypted connection to true client.EnableSsl = true; client.Timeout = 100000; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Credentials = new NetworkCredential(senderEmail, senderPassword); // Whrite email MailMessage mailMessage = new MailMessage(senderEmail, userModel.Email, subject, emailBody); mailMessage.IsBodyHtml = true; mailMessage.BodyEncoding = UTF8Encoding.UTF8; client.Send(mailMessage); return(true); } catch (Exception ex) { return(false); } }