protected void btnLogin_ServerClick(object sender, EventArgs e) { BLUser blUser = new BLUser(); try { DataSet dsUsers = blUser.GetUser(txtUserName.Value, txtPassword.Value); if (dsUsers.Tables.Count > 0) { if (dsUsers.Tables[0].Rows.Count == 0) { //Invalid User msg = "Username หรือ Password ผิดพลาด กรุณา Login ใหม่"; } else { actionResult = true; User users = new User(); users.UserId = dsUsers.Tables[0].Rows[0]["USER_ID"].ToString(); //users.UserName = dsUsers.Tables[0].Rows[0]["USER_NAME"].ToString(); users.UserName = dsUsers.Tables[0].Rows[0]["CUSTOMER_DESCRIPTION"].ToString(); users.DeptId = dsUsers.Tables[0].Rows[0]["DEPT_ID"].ToString(); users.Email = dsUsers.Tables[0].Rows[0]["EMAIL"].ToString(); users.DeptName = dsUsers.Tables[0].Rows[0]["DEPT_NAME"].ToString(); users.RoleMenus = new List <string>(); foreach (DataRow dr in dsUsers.Tables[0].Rows) { users.RoleMenus.Add(dr["MENU_ID"].ToString()); } Session["User"] = users; if (chkRemember.Checked) { Session.Timeout = 3000; } Response.Redirect("Home/Index.aspx"); } } else { msg = "Username หรือ Password ผิดพลาด กรุณา Login ใหม่"; } } catch (Exception ex) { throw ex; } }
public virtual void NewAccount(VM2 model) { if (ModelState.IsValid) { if (BLUser <ET> .Create(HelpersMethods.CopyValues <VM2, ET>(model))) { this.AddToastMessage("Sucesso", "Conta criada com sucesso", ToastrType.Success); } else { this.AddToastMessage("Erro", "Erro ao registrar, favor tentar novamente", ToastrType.Error); } } }
public void SetUserCheckPageTitle_UserCheckPageTitleIsSet_WhenUserFullNameIsNotNull() { // Arrange BLUser User = new BLUser { FullName = "Teszt Elek" }; string expectedTitle = "Teszt Elek Bakancslistái"; // Act string actualTitle = _bucketListService.SetUserCheckPageTitle(User); // Assert Assert.Equal(expectedTitle, actualTitle); }
public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList(); if (ModelState.IsValid) { var user = new BLUser { FullName = Input.FullName, UserName = Input.Email, Email = Input.Email, SeededUser = false }; var result = await _userManager.CreateAsync(user, Input.Password); if (result.Succeeded) { _logger.LogInformation("User created a new account with password."); var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); var callbackUrl = Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { area = "Identity", userId = user.Id, code = code }, protocol: Request.Scheme); await _emailSender.SendEmailAsync(Input.Email, "Confirm your email", $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>."); if (_userManager.Options.SignIn.RequireConfirmedAccount) { return(RedirectToPage("RegisterConfirmation", new { email = Input.Email })); } else { await _signInManager.SignInAsync(user, isPersistent : false); return(LocalRedirect(returnUrl)); } } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } // If we got this far, something failed, redisplay form return(Page()); }
/// <summary> /// Changes money /// </summary> /// <param name="user"></param> /// <param name="money"></param> /// <exception cref="ValidateException">Thrown if parameter was null</exception> public void ChangeUsersInfo(BLUser user, decimal money) { if (user is null) { throw new ValidateException("The user cannot be null"); } User user1 = DB.Users.Get(user.Id); if (user1 is null) { throw new ValidateException("The user cannot be null"); } user1.Money = money; }
/// <summary> /// Changes the email of user /// </summary> /// <param name="user"></param> /// <param name="email"></param> /// <exception cref="ValidateException">Thrown if parameter was null</exception> public void ChangeUsersEmail(BLUser user, string email) { if (user is null) { throw new ValidateException("The user cannot be null"); } User user1 = DB.Users.Get(user.Id); if (user1 is null) { throw new ValidateException("The user cannot be null"); } user1.Email = email; }
private void btLogin_Click(object sender, EventArgs e) { //BLUser bluser = new BLUser(); User user = BLUser.Valid("admin", "admin"); if (user == null) { MessageBox.Show("failed"); } else { MessageBox.Show(user.UserTrueName); } }
/// <summary> /// Changes a password of user /// </summary> /// <param name="user"></param> /// <param name="password"></param> /// <exception cref="ValidateException">Thrown if parameter was null</exception> public void ChangeUsersPassword(BLUser user, string password) { if (user is null) { throw new ValidateException("The user cannot be null"); } User user1 = DB.Users.Get(user.Id); if (user1 is null) { throw new ValidateException("The user cannot be null"); } user1.Pasword = password; }
//[RestAuthenticationAttribute] public IEnumerable <VehicleCommonInfo> GetUserVehiclesInfo(GetUserVehiclesInfoRequest request) { BLUser userData = new BLUser(); request.DecodeAuthToken(); IEnumerable <VehicleCommonInfo> vehicleInfoList = null; //userData = GlobalData.GetSessionProperty(request.SID, userData.GetType()); userData = CachingLayer.GetCacheObjectByType(request.SID, userData.GetType()); if (userData != null) { vehicleInfoList = userData.GetOnlineVehiclesInfo(false, string.Empty).Tables[0].DataTableToList <VehicleCommonInfo>(); } return(vehicleInfoList); }
/// <summary> /// Changes name and last of user /// </summary> /// <param name="user"></param> /// <param name="name"></param> /// <param name="lastname"></param> /// <exception cref="ValidateException">Thrown if parameter was null</exception> public void ChangeUsersInfo(BLUser user, string name, string lastname) { if (user is null) { throw new ValidateException("The user cannot be null"); } User user1 = DB.Users.Get(user.Id); if (user1 is null) { throw new ValidateException("The user cannot be null"); } user1.FirstName = name; user1.LastName = lastname; }
//[RestAuthenticationAttribute] public IEnumerable <VehicleType> GetVehicleTypes(GetVehicleTypesRequest request) { request.DecodeAuthToken(); BLUser userData = new BLUser(); userData = CachingLayer.GetCacheObjectByType(request.SID, userData.GetType()); IEnumerable <VehicleType> vehicleTypeList = null; if (userData != null) { BLUtils utils = new BLUtils(); vehicleTypeList = utils.GetVehicleTypes(userData.CompanyId).DataTableToList <VehicleType>(); } return(vehicleTypeList); }
protected void RequestButton_Click(object sender, EventArgs e) { if (IsValid) { // Check if email exists in the system; reload page and display error if not -- X // If exists, update password to random generated string; password is hashed for security string randomCode = BLPassword.RandomString(10, true); // Retrieve user corresponding to email address of account and update password BLUser user = new BLUser(); user = user.getUserByEmail(EmailTextBox.Text); BLUser.updateUserPassword(user, randomCode); // Attach email address and hashed password as parameters for url to update password (sent in the email) string mailbody = "<p>" + "Hi," + "</p>" + "<p>" + "Below is the verification link needed to update your password (click to update):" + "</p>" + "<p>" + "https://localhost:44326/UL/ChangePassword/" + EmailTextBox.Text + "/" + randomCode + "</p>" + "<br/>" + "<p>" + "Kind Regards," + "</p>" + "<p>" + "The JerseySure Team" + "</p>"; try { BLEmail.SendEmail(EmailTextBox.Text, "Verification Link - JerseySure", mailbody); } catch (Exception ex) { // Display error page for unable to send email Response.Redirect("~/UL/ErrorPage/1"); } // Display success status of email being sent Response.Redirect("~/UL/SuccessPage/0"); } }
static void CreateProduct() { if (user is RegisteredUserView) { Console.WriteLine("Access deny"); return; } try { BLUser bLUser = new BLUser() { Basket = new MapperConfiguration(cfg => cfg.CreateMap <ProductView, BLProduct>()).CreateMapper().Map <IEnumerable <ProductView>, List <BLProduct> >(user.Basket), Orders = new MapperConfiguration(cfg => cfg.CreateMap <OrderView, BLOrder>()).CreateMapper().Map <IEnumerable <OrderView>, List <BLOrder> >(user.Orders), Email = user.Email, FirstName = user.FirstName, Id = user.Id, LastName = user.LastName, Money = user.Money, NumberofCard = user.NumberofCard, Pasword = user.Pasword }; Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("\nCategory: "); string category = Console.ReadLine(); Console.Write("\nDescription: "); string description = Console.ReadLine(); Console.Write("\nPrice: "); decimal price = Convert.ToDecimal(Console.ReadLine()); BLProduct product = new BLProduct() { Category = category, Description = description, Name = name, Price = price }; productService.CreateProduct(product); } catch (ValidateException ex) { Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// Returns all orders by user /// </summary> /// <param name="user">User whose order will be got</param> /// <returns>An IEnumerable of orders</returns> /// <exception cref="ValidateException">Thrown if user was null</exception> public IEnumerable <BLOrder> GetOrders(BLUser user) { if (user is null) { throw new ValidateException("The user cannot be null"); } User u = DB.Users.Get(user.Id); foreach (var order in u.Orders) { yield return(new BLOrder() { Id = order.Id, Country = order.Country, NumberOfPost = order.NumberOfPost, ProductId = order.ProductId, Status = order.Status }); } }
public void ReadUserTest() { int id = 0; List <string> errors = new List <string>(); //id = 0 BLUser.ReadUser(id, ref errors); Assert.AreEqual(1, errors.Count); AsynchLog.LogNow(errors); //no errors errors = new List <string>(); BLUser.ReadUser(1, ref errors); Assert.AreEqual(0, errors.Count); AsynchLog.LogNow(errors); }
private void cargarUsuarios() { cboUsuarios.DataSource = null; BLUser usuarios = new BLUser(); DataTable datos = usuarios.fnUsuariosAll(); DataView vista = datos.AsDataView(); vista.RowFilter = "Estado=0"; vista.Sort = "NombreUsuario"; cboUsuarios.DataSource = vista; cboUsuarios.DisplayMember = "NombreUsuario"; cboUsuarios.ValueMember = "HotelID"; dv_usuario = vista; // string f = dv_usuario[4][77].ToString(); }
public JsonResult GetFilteredUsers(string division_Code, string user_Type_Code) { try { BLUser objUser = new BLUser(); _objCurrentInfo = new CurrentInfo(); string company_Code = _objCurrentInfo.GetCompanyCode(); IEnumerable <DivisionUserProducts> IlstUsers = objUser.GetUserBasedOnDivisionAndUserType(company_Code, division_Code, user_Type_Code); return(Json(IlstUsers)); } catch { throw; } }
/// <summary> /// Returns the products which are in the user`s basket /// </summary> /// <param name="user">User whose basket will be got</param> /// <returns>IEnumerable of products</returns> /// <exception cref="ValidateException">Thrown if parameter was null</exception> public IEnumerable <BLProduct> GetBasket(BLUser user) { if (user is null) { throw new ValidateException("The user cannot be null"); } User u = DB.Users.Get(user.Id); foreach (var pro in u.Basket) { yield return(new BLProduct() { Id = pro.Id, Category = pro.Category, Description = pro.Description, Name = pro.Name, Price = pro.Price }); } }
//Single Device Lock Release public JsonResult GetSingleDeviceEntriesByGuid(string LoginUserCode) { IEnumerable <SingleDeviceGUID> lstUser = new List <SingleDeviceGUID>(); try { BLUser objDept = new BLUser(); lstUser = objDept.GetSingleDeviceEntriesByGuid(LoginUserCode).ToList(); } catch (Exception ex) { Dictionary <string, string> dicContext = new Dictionary <string, string>(); DataControl.Impl.ExceptionHandler.WriteLog(ex, dicContext); } return(Json(lstUser, JsonRequestBehavior.AllowGet)); }
public static bool CheckRoleAccessRight(string userName, params SystemRoles[] roles) { var roleList = roles.Select(r => Enum.GetName(r.GetType(), r)).ToList(); for (int i = 0; i < roleList.Count; i++) { roleList[i] = roleList[i].Replace("_", " "); } if (SmUserRolesList.UserRoles == null) { var blUser = new BLUser(); SmUserRolesList.UserRoles = blUser.GetAllUserRoles(); } return(SmUserRolesList.UserRoles.Any(r => r.UserName == userName && roleList.Contains(r.RoleName))); }
// Performs the submission of updated account settings protected void btnUpdate_Click(object sender, EventArgs e) { if (IsValid) { BLUser currentUser = Session["CurrentUser"] as BLUser; // Fills the hidden address section if (cbxPostageSame.Checked && !currentUser.userAdmin) { tbxPostAddress.Text = tbxBillAddress.Text; tbxPostSuburb.Text = tbxBillSuburb.Text; ddlPostState.SelectedIndex = ddlBillState.SelectedIndex; tbxPostPostCode.Text = tbxBillPostCode.Text; } string billPostCode = currentUser.userAdmin ? "0" : tbxBillPostCode.Text; BLUser user = new BLUser { userID = currentUser.userID, userFirstName = tbxFirstName.Text, userLastName = tbxLastName.Text, userEmail = tbxEmail.Text, userPhone = tbxPhone.Text, billAddress = BLAddress.fillAddress('B', tbxBillAddress.Text, tbxBillSuburb.Text, ddlBillState.SelectedValue, Convert.ToInt32(billPostCode)), postAddress = BLAddress.fillAddress('P', tbxPostAddress.Text, tbxPostSuburb.Text, ddlPostState.SelectedValue, Convert.ToInt32(tbxPostPostCode.Text)), userAdmin = currentUser.userAdmin, userActive = currentUser.userActive }; if (BLUser.updateUser(user)) { Session["Name"] = user.userFirstName; Session["CurrentUser"] = user; Session["UserName"] = user.userEmail; Response.Redirect("~/UL/SuccessPage/4"); } else { Response.Redirect("~/UL/ErrorPage/9"); } Response.Redirect("~/UL/AccountSettings"); } }
public void DownloadSubList() { DataControl.BLUser objUser = new BLUser(); DataControl.CurrentInfo objCurInfo = new CurrentInfo(); string companyCode = objCurInfo.GetCompanyCode(); DataSet Ds = new DataSet(); Ds = objUser.DownloadSubList(companyCode); Ds.Tables[0].TableName = "State Details"; Ds.Tables[1].TableName = "City Details"; Ds.Tables.RemoveAt(3); Ds.Tables.RemoveAt(2); HttpResponse response = System.Web.HttpContext.Current.Response; DownloadExcel excel = new DownloadExcel(); excel.Convert(Ds, "State_City" + "_" + DateTime.Now.ToShortDateString(), response); }
/// <summary> /// Inserts a new user /// </summary> /// <param name="user"></param> /// <returns></returns> public int addNewUser(BLUser user) { string cs = ConfigurationManager.ConnectionStrings["JerseySure"].ConnectionString; int rows; using (SqlConnection connection = new SqlConnection(cs)) { SqlCommand command = new SqlCommand("usp_addUser", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@userFirst", user.userFirstName); command.Parameters.AddWithValue("@userLast", user.userLastName); command.Parameters.AddWithValue("@userEmail", user.userEmail); command.Parameters.AddWithValue("@userPhone", user.userPhone); command.Parameters.AddWithValue("@userPassword", user.userPassword); command.Parameters.AddWithValue("@userAdmin", user.userAdmin); command.Parameters.AddWithValue("@userActive", user.userActive); SqlParameter billStreet = new SqlParameter("@billStreet", SqlDbType.VarChar); SqlParameter billSuburb = new SqlParameter("@billSuburb", SqlDbType.VarChar); SqlParameter billState = new SqlParameter("@billState", SqlDbType.Char); SqlParameter billZip = new SqlParameter("@billZip", SqlDbType.Int); billStreet.Value = user.userAdmin ? "" : user.billAddress.addStreet; billSuburb.Value = user.userAdmin ? "" : user.billAddress.addSuburb; billState.Value = user.userAdmin ? "" : user.billAddress.addState; billZip.Value = user.userAdmin ? 0 : user.billAddress.addZip; command.Parameters.Add(billStreet); command.Parameters.Add(billSuburb); command.Parameters.Add(billState); command.Parameters.Add(billZip); command.Parameters.AddWithValue("@postStreet", user.postAddress.addStreet); command.Parameters.AddWithValue("@postSuburb", user.postAddress.addSuburb); command.Parameters.AddWithValue("@postState", user.postAddress.addState); command.Parameters.AddWithValue("@postZip", user.postAddress.addZip); connection.Open(); rows = command.ExecuteNonQuery(); } return(rows); }
static void CreateOrder() { try { BLUser bLUser = new BLUser() { Basket = new MapperConfiguration(cfg => cfg.CreateMap <ProductView, BLProduct>()).CreateMapper().Map <IEnumerable <ProductView>, List <BLProduct> >(user.Basket), Orders = new MapperConfiguration(cfg => cfg.CreateMap <OrderView, BLOrder>()).CreateMapper().Map <IEnumerable <OrderView>, List <BLOrder> >(user.Orders), Email = user.Email, FirstName = user.FirstName, Id = user.Id, LastName = user.LastName, Money = user.Money, NumberofCard = user.NumberofCard, Pasword = user.Pasword }; Console.Write("ProductId: "); int productId = Convert.ToInt32(Console.ReadLine()); while (productId < 0 || productId > productService.GetBasket(bLUser).Count()) { Console.WriteLine("\nWrite a number one more time"); productId = Convert.ToInt32(Console.ReadLine()); } Console.Write("\nCountry: "); string country = Console.ReadLine(); Console.Write("\nNumber of post: "); int number = Convert.ToInt32(Console.ReadLine()); BLOrder order = new BLOrder() { Country = country, NumberOfPost = number, ProductId = productId, Status = Statuses.New }; orderService.MakeOrder(bLUser, order); } catch (ValidateException ex) { Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public string fnGetAccountIsLock(string userCode) { try { string userLock = ""; string companyCode = _objCurInfo.GetCompanyCode(); BLUser objBLuser = new BLUser(); userLock = objBLuser.GetAccountlock(userCode); return(userLock); } catch (Exception ex) { Dictionary <string, string> dicContext = new Dictionary <string, string>(); dicContext.Add("Filter:UserName", userCode); DataControl.Impl.ExceptionHandler.WriteLog(ex, dicContext); throw new Exception("Sorry an error occurred. Please try again later"); } }
/// <summary> /// Change the status of order /// </summary> /// <param name="user">User whose order will be got</param> /// <param name="id">The id of order</param> /// <param name="status">The status the will be set to the order</param> /// <exception cref="ValidateException">Thrown if parameter was null</exception> public void ChangeStatus(BLUser user, int?id, Statuses status) { if (id is null) { throw new ValidateException("The id cannot be null"); } if (user is null) { throw new ValidateException("The user cannot be null"); } Order orderMain = DB.Users.Get(user.Id).Orders.Find(f => f.Id == id); if (orderMain is null) { throw new ValidateException("The order cannot be null"); } orderMain.Status = status; }
private void InitialDropdown() { try { BLUser blUser = new BLUser(); DataSet ds = new DataSet(); ds = blUser.GetUserType(); ddlUserType.DataSource = ds; ddlUserType.DataTextField = "USER_TYPE_NAME"; ddlUserType.DataValueField = "USER_TYPE_ID"; ddlUserType.DataBind(); ddlUserType.Items.Insert(0, new ListItem("ALL", "")); } catch (Exception ex) { throw ex; } }
//[RestAuthenticationAttribute] public IEnumerable <GroupsDataInfo> GetGroupsData(GetUserGroupsDataRequest request) { BLUser userData = new BLUser(); request.DecodeAuthToken(); userData = CachingLayer.GetCacheObjectByType(request.SID, userData.GetType()); VehicleTreeDS.VEHICLE_GROUPSRow temp = userData.GetVehicleGroupsDS().VEHICLE_GROUPS.FindByVTR_NODE_ID(userData.VehicleNodeId); List <GroupsDataInfo> groupsDataInfo = temp.Table.DataTableToList <GroupsDataInfo>().ToList(); /*groupsDataInfo.Add(new GroupsDataInfo() * { * VTR_COMPANY_ID=temp.VTR_COMPANY_ID, * VTR_NODE_ID=temp.VTR_NODE_ID, * VTR_NODE_NAME=temp.VTR_NODE_NAME * });*/ return(groupsDataInfo); }
public JsonResult GetHDAccessUsersDetails(string LoginUserCode) { //String CompanyCode = ""; //CompanyCode = _objCurrentInfo.GetCompanyCode(); List <HDAccessDetails> lstUser = new List <HDAccessDetails>(); try { BLUser objDept = new BLUser(); lstUser = objDept.GetHDAccessUsersDetails(LoginUserCode).ToList(); } catch (Exception ex) { Dictionary <string, string> dicContext = new Dictionary <string, string>(); DataControl.Impl.ExceptionHandler.WriteLog(ex, dicContext); } return(Json(lstUser, JsonRequestBehavior.AllowGet)); }
//[RestAuthenticationAttribute]/*only with DB connection*/ public IEnumerable <VehicleMapInfo> GetMapData(GetMapDataRequest request) { request.DecodeAuthToken(); BLUser userData = new BLUser(); //userData = GlobalData.GetSessionProperty(request.SID, userData.GetType()); userData = CachingLayer.GetCacheObjectByType(request.SID, userData.GetType()); IEnumerable <VehicleMapInfo> vehicleMapInfo = null; if (userData != null) { vehicleMapInfo = MapsDAL.GetVehicleList(-180, -90, 180, 90, userData.CompanyId, request.VehicleIDs, -1).DataTableToList <VehicleMapInfo>(); GoogleObject GObj = new GoogleObject(); GetMapDataFacade facade = new GetMapDataFacade(); facade.createMapDataObject(ref GObj, vehicleMapInfo.ToList()); } return(vehicleMapInfo); }
public int Update() { int returnValue = 0; if (this.id>0) { BLUser oldUser = new BLUser(); oldUser.ID = this.id; oldUser.Retrieve(); if (oldUser.ID > 0 ) { if (oldUser.Login!=this.login || oldUser.Password!=this.password) { this.uid=Guid.NewGuid().ToString(); } } } else { this.uid=Guid.NewGuid().ToString(); } returnValue = Update(this.id, this.customer.ID, this.uid, this.enabled, this.login, this.password, this.email, this.created); this.id = returnValue; return returnValue; }
private void btnForgotpass_Click(object sender, System.Web.UI.ImageClickEventArgs e) { if (Page.IsValid) { if (this.emailNotification) { BLUser wUser = new BLUser(); wUser.EMail = txtEMail.Text.Trim().ToLower(); wUser.Retrieve(); if (wUser.ID>0 && wUser.Enabled) { StringWriter writer = new StringWriter(); Server.Execute("email/emailForgotPass.aspx?email="+wUser.EMail, writer); string strhtmlbody = writer.ToString(); // Response.Write(strhtmlbody); // Response.End(); MailMessage objMailMessage = new MailMessage(); objMailMessage.Subject = siteName+": your password"; objMailMessage.From = this.emailNotificationCustomerFrom; objMailMessage.To = wUser.EMail; objMailMessage.Cc = this.emailNotificationCustomerCc; objMailMessage.Bcc = this.emailNotificationCustomerBcc; objMailMessage.Body = strhtmlbody; objMailMessage.BodyFormat = MailFormat.Html; SmtpMail.SmtpServer = this.smtpServer; SmtpMail.Send( objMailMessage ); } } Response.Redirect(".?page=login"); } }