public ActionResult SearchUser(UserCommon UC) { ViewBag.SearchFilter = ApplicationUtilities.SetDDLValue(LoadDropdownList("searchfilter") as Dictionary <string, string>, UC.SearchFilter, "--Select--"); if (!string.IsNullOrEmpty(UC.SearchField) || !string.IsNullOrEmpty(UC.SearchFilter)) { string username = Session["username"].ToString(); var lst = buss.GetSearchUserList(UC.SearchField, UC.SearchFilter, username); foreach (var item in lst) { item.Status = "<span class='badge badge-" + (item.IsActive.Trim().ToUpper() == "Y" ? "success" : "danger") + "'>" + (item.IsActive.Trim().ToUpper() == "Y" ? "Active" : "Blocked") + "</span>"; } IDictionary <string, string> param = new Dictionary <string, string>(); param.Add("AgentUserId", "Agent Id"); param.Add("FullName", "Full Name"); param.Add("UserName", "User Name"); param.Add("Email", "Email"); param.Add("Status", "Status"); param.Add("PhoneNo", "Mobile Number"); param.Add("CreatedBy", "Created By"); param.Add("CreateDate", "Created On"); ProjectGrid.column = param; //Ends var grid = ProjectGrid.MakeGrid(lst, "hidebreadcrumb", "", 10, false, "", "", "", "", "", ""); ViewData["grid"] = grid; } else { this.ShowPopup(1, "Please Fill the fields"); } return(View(UC)); }
public ActionResult EditSearchUser(string UserId = "") { UserCommon commonModel = new UserCommon(); if (!string.IsNullOrEmpty(UserId)) { var id = UserId.DecryptParameter(); if (string.IsNullOrEmpty(id)) { return(RedirectToAction("SearchUser")); } string username = Session["username"].ToString(); commonModel = buss.GetSearchUserList(id, "userid", username).FirstOrDefault(); //commonModel = buss.GetUserById(id); commonModel.UserID = commonModel.UserID.EncryptParameter(); var rol = LoadDropdownList("ManageUser"); ViewBag.Roles = ApplicationUtilities.SetDDLValue(LoadDropdownList("ManageUser") as Dictionary <string, string>, commonModel.RoleId, "--Select Role--"); return(View(commonModel)); } else { ApplicationUtilities.ShowPopup(this, 1, "Something Went Wrong! "); return(RedirectToAction("SearchUser")); } //ViewBag.Roles = LoadDropdownList("ManageUser"); }
public ActionResult ResetPassword(User user) { try { User _user = UserCommon.GetInstance().Get(user).FirstOrDefault(); if (!_user.blocked.Equals("SIM")) { string _newPassword = Password.Create(); _user.password = Cripto.GetHash(_newPassword); _user.change_password = 1; UserCommon.GetInstance().Update(_user); string body = EmailTemplate.ResetPassword(_user.nome_user, _newPassword); Email email = new Email() { recipient = _user.email, subject = "Recuperação de Senha", body = body }; Mail.Send(email); var response = "Uma nova senha foi encaminhada por e-mail"; return(Json(new { retorno = response })); } else { var response = "O usuário está bloqueado"; return(Json(new { retorno = response })); } } catch { var response = "error"; return(Json(new { retorno = response })); } }
public List <UserCommon> GetAllList(string User, string usertype, int Pagesize) { var sql = "Exec sproc_user_detail "; sql += "@flag = 'lglst' "; sql += ",@user_name = " + dao.FilterString(User); sql += ",@usr_type = " + dao.FilterString(usertype); //sql += ",@Search = " + dao.FilterString(Search); //sql += ",@Page_size = " + dao.FilterString(Pagesize.ToString()); var dt = dao.ExecuteDataTable(sql); var list = new List <UserCommon>(); if (null != dt) { int sn = 1; foreach (DataRow item in dt.Rows) { var common = new UserCommon { UserID = item["User_ID"].ToString(), FullName = item["Full_Name"].ToString(), Email = item["user_email"].ToString(), PhoneNo = item["user_mobile_no"].ToString(), CreateDate = item["created_local_date"].ToString(), CreatedBy = item["created_by"].ToString(), IsActive = item["status"].ToString(), UserName = item["user_name"].ToString() }; sn++; list.Add(common); } } return(list); }
public ActionResult CreateAction(string user, string pass, int group, string diachi, string ngaysinh, string hoten, string email, string sdt, string CMND) { Login us = new Login(); us.UserName = user; us.PassWord = pass; us.Group = group; KhachHang kh = new KhachHang(); kh.HoTen = hoten; // kh.NgaySinh = DateTime.Parse(ngaysinh,"dd/mm/yyyy"); kh.Email = email; kh.SDT = sdt; kh.DiaChi = diachi; var dao = new UserCommon(); int n = dao.Insert(us, kh); if (n == -1) { ModelState.AddModelError("", "Tài khoản đã tồn tại"); return(View("Create")); } else { ModelState.AddModelError("", "Thêm tài khoản thành công!"); return(RedirectToAction("Index", "User")); } }
public void OnAuthorization(AuthorizationFilterContext context) { if (context.Filters.Any(filter => filter is IAllowAnonymousFilter)) { return; } var token = MemberShiper.AppAuthorize.Token; if (string.IsNullOrEmpty(token)) { ReponseEnd(new ResultMo(ResultTypes.UnAuthorize, "用户未登录!"), context); return; } var userRes = UserCommon.GetCurrentUser().Result; if (!userRes.IsSuccess()) { ReponseEnd(userRes, context); return; } MemberShiper.SetIdentity(new MemberIdentity() { Id = userRes.data.id, MemberInfo = userRes.data }); }
public UserCommon GetUserById(string UserId) { var sql = "Exec sproc_user_detail "; sql += "@flag = 'v' "; sql += ",@user_id = " + dao.FilterString(UserId); var dt = dao.ExecuteDataTable(sql); var item = new UserCommon(); if (null != dt) { int sn = 1; foreach (DataRow dr in dt.Rows) { item = new UserCommon { UserID = dr["User_ID"].ToString(), FullName = dr["Full_Name"].ToString(), Email = dr["user_email"].ToString(), PhoneNo = dr["user_mobile_no"].ToString(), CreateDate = dr["created_local_date"].ToString(), CreatedBy = dr["created_by"].ToString(), IsActive = dr["status"].ToString(), UserName = dr["user_name"].ToString(), RoleId = dr["usr_type_id"].ToString() }; return(item); } } return(item); }
public CommonDbResponse ManageUser(UserCommon setup) { var sql = "Exec sproc_user_detail "; sql += "@flag = '" + (string.IsNullOrEmpty(setup.UserID) ? "i" : "u") + "' "; sql += ",@full_name = " + dao.FilterString(setup.FullName); sql += ",@email = " + dao.FilterString(setup.Email); sql += ",@mobile = " + dao.FilterString(setup.PhoneNo); sql += "," + (string.IsNullOrEmpty(setup.UserID) ? "@created_by" : "@updated_by") + " = " + dao.FilterString(setup.ActionUser); sql += ",@usr_type_id = '1'"; sql += ",@role_id = " + dao.FilterString(setup.RoleId); if (string.IsNullOrEmpty(setup.UserID)) { sql += ",@user_name = " + dao.FilterString(setup.UserName); sql += ",@password = "******",@created_ip = " + dao.FilterString(setup.IpAddress); sql += ",@created_platform = " + dao.FilterString(setup.CreatedPlatform); sql += ",@status = " + dao.FilterString(setup.IsActive); } else { sql += ",@user_id = " + dao.FilterString(setup.UserID); } return(dao.ParseCommonDbResponse(sql)); }
private JsonResult CreateResultJson(UserViewModel viewModel) { if (_service.ExistedName(viewModel.Entity.UserName)) { return(Json(new { result = Constants.Duplicate })); } if (_service.ExistedEmail(viewModel.Entity.Email)) { return(Json(new { result = Constants.DuplicateEmail })); } try { viewModel.Entity.Enable = true; viewModel.Entity.Password = UserCommon.CreateHash(viewModel.Entity.Password); viewModel.Entity.CreatedBy = viewModel.LoginId; viewModel.Entity.Created = DateTime.Now; _service.Insert(viewModel.Entity); return(Json(new { result = Constants.Success })); } catch (Exception e) { Log.Error("Create New User!", e); return(Json(new { result = Constants.UnSuccess })); } }
public async Task <UserCommonResponse> UpdateAsync(int id, UserCommon userCommon) { var existingUserCommon = await _userCommonRepository.FindById(id); if (existingUserCommon == null) { return(new UserCommonResponse("UserChef not found")); } existingUserCommon.Name = userCommon.Name; existingUserCommon.Lastname = userCommon.Lastname; existingUserCommon.Membership = userCommon.Membership; existingUserCommon.Email = userCommon.Email; existingUserCommon.Password = userCommon.Password; existingUserCommon.Picture = userCommon.Picture; existingUserCommon.Date = userCommon.Date; try { _userCommonRepository.Update(existingUserCommon); await _unitOfWork.CompleteAsync(); return(new UserCommonResponse(existingUserCommon)); } catch (Exception ex) { return(new UserCommonResponse($"An error ocurred while updating the UserCommon: {ex.Message}")); } }
public ActionResult EditAction(string user, string pass, int group, string diachi, string hoten, string email, string sdt, string CMND) { Login model = new Login(); model.UserName = user; model.PassWord = pass; model.Group = group; KhachHang kh = new KhachHang(); kh.HoTen = hoten; kh.DiaChi = diachi; kh.Email = email; kh.SDT = sdt; kh.CMND = CMND; UserCommon dao = new UserCommon(); bool kt = dao.Edit(model, kh); if (kt) { ModelState.AddModelError("", "Sửa tài khoản thành công!"); return(RedirectToAction("Index", "User")); } else { ModelState.AddModelError("", "Sửa không thành công"); return(View("Edit/?username="******"User")); } }
public ActionResult ManageUser(UserCommon model) { ViewBag.Roles = ApplicationUtilities.SetDDLValue(LoadDropdownList("ManageUser") as Dictionary <string, string>, model.RoleId, "--Select Role--"); //model.Roles = LoadDropdownList("ManageUser") as List<SelectListItem>; string userId = ""; userId = model.UserID; if (!string.IsNullOrEmpty(model.UserID)) { if (string.IsNullOrEmpty(model.UserID.DecryptParameter())) { return(RedirectToAction("Index")); } model.UserID = userId.DecryptParameter(); } ModelStateValidation(String.IsNullOrEmpty(userId) ? "Insert" : "Update"); if (ModelState.IsValid) { model.ActionUser = Session["username"].ToString(); buss.ManageUser(model).SetMessageInTempData(this); return(RedirectToAction("Index")); } model.UserID = userId; return(View(model)); }
public ActionResult ChangePassword(UserModel userModel) { string dbmessage = string.Empty; ModelState.Remove("UserPin"); ModelState.Remove("ConfirmUserPin"); userModel.UserName = Session["username"].ToString(); if (ModelState.IsValid) { string oldpwd = userModel.OldPassword; string newpwd = userModel.UserPwd; string username = userModel.UserName; UserCommon user = new UserCommon { OldPassword = oldpwd, UserName = username, UserPwd = newpwd, Session = Session.SessionID }; CommonDbResponse dbresp = _userBusiness.ChangePassword(user); if (dbresp.Code == 0) { this.ShowPopup(0, dbresp.Message); return(RedirectToAction("Index", "Home")); } dbmessage = dbresp.Message; } this.ShowPopup(1, string.IsNullOrEmpty(dbmessage) ? "Invalid Current Password" : dbmessage); return(View(userModel)); }
public ActionResult Edit(string username) { var dao = new UserCommon(); Login user = dao.GetByUsername(username); ViewBag.username = username; return(View(user)); }
// // GET: /Admin/User/ public ActionResult Index(string tkstring, int page = 1, int pagesize = 10) { var dao = new UserCommon(); var model = dao.ListUser(tkstring, page, pagesize); ViewBag.tk = tkstring; return(View(model)); }
public ActionResult Login(User user) { try { User _user = UserCommon.GetInstance().Get(new User() { email = user.email }).FirstOrDefault(); if (_user != null) { if (_user.password.Equals(Cripto.GetHash(user.password))) { if (!_user.blocked.Equals("SIM")) { IncorrectAttempt(_user, true); var response = _user; return(Json(new { retorno = "/MyAccount/Index" })); } else { var response = "Usuário bloqueado!"; return(Json(new { retorno = response })); } } else { if (_user.attempts == 1) { IncorrectAttempt(_user, false); var response = "Senha incorreta! O cadastro será bloqueado na próxima tentativa errada."; return(Json(new { retorno = response })); } else if (_user.attempts >= 2) { IncorrectAttempt(_user, false); var response = "Senha incorreta! O cadastro está bloqueado."; return(Json(new { retorno = response })); } else { IncorrectAttempt(_user, false); var response = "Senha incorreta!"; return(Json(new { retorno = response })); } } } else { var response = "Usuário não encontrado"; return(Json(new { retorno = response })); } } catch { var response = "error"; return(Json(new { retorno = response })); } }
public List <UserCommon> GetSearchUserList(string SearchField, string SearchFilter, string username = "") { var sql = "Exec sproc_user_detail "; sql += " @flag='searchfilteruser'"; sql += ", @action_user="******"email") { sql += " ,@email=" + dao.FilterString(SearchField); } if (SearchFilter.ToLower() == "mobileno") { sql += " ,@mobile=" + dao.FilterString(SearchField); } if (SearchFilter.ToLower() == "username") { sql += " ,@user_name=" + dao.FilterString(SearchField); } if (SearchFilter.ToLower() == "fullname") { sql += " ,@full_name=" + dao.FilterString(SearchField); } if (SearchFilter.ToLower() == "userid") { sql += " ,@search=" + dao.FilterString(SearchField); } var dt = dao.ExecuteDataTable(sql); var list = new List <UserCommon>(); if (null != dt) { int sn = 1; foreach (DataRow item in dt.Rows) { var common = new UserCommon { UserID = item["User_ID"].ToString(), AgentUserId = item["Agent_id"].ToString(), FullName = item["Full_Name"].ToString(), UserName = item["user_name"].ToString(), Email = item["user_email"].ToString(), PhoneNo = item["user_mobile_no"].ToString(), CreateDate = item["created_local_date"].ToString(), CreatedBy = item["created_by"].ToString(), IsActive = item["status"].ToString(), IsPrimary = item["is_primary"].ToString(), Allow_Multiple_Login = item["allow_multiple_login"].ToString().Trim() //identification photo logo }; sn++; list.Add(common); } } return(list); }
public CommonDbResponse ChangePassword(UserCommon user) { var sql = "Exec sproc_user_detail "; sql += " @flag='changepwd'"; sql += ", @password="******", @new_password="******", @user_name=" + dao.FilterString(user.UserName); return(dao.ParseCommonDbResponse(sql)); }
private static PasswordCreation CreatePassword(IDictionary session) { var passwordId = Guid.NewGuid().ToString(); var password = UserCommon.GeneratePassword(); session[passwordId] = password; var passwordCreation = new PasswordCreation(password, passwordId); return(passwordCreation); }
public ActionResult Index() { var db = new TableContext(); int userId = int.Parse(TempData["userId"].ToString()); var user = db.Users.Where(u => u.Id == userId).FirstOrDefault(); var userDTO = UserCommon.ConvertBOtoDTO(user); return(View(userDTO)); }
public ActionResult SignUp() { UserCommon model = new UserCommon(); //Uri url = Request.Url; var resp = new DbResponse(); resp.ErrorCode = 1; resp.Message = "testing message in session"; StaticData.SetMessageInSession(resp); return(View(model)); }
public CommonDbResponse ChangePin(UserCommon user) { var sql = "Exec sproc_user_detail "; sql += " @flag='wmp', @mode='r'"; //mode u for update s for first time change sql += ", @old_mpin=" + dao.FilterString(user.UserPin); sql += ", @mpin=" + dao.FilterString(user.UserPin); sql += ", @password="******", @user_id=" + dao.FilterString(user.UserID); sql += ", @action_user=" + dao.FilterString(user.UserName); return(dao.ParseCommonDbResponse(sql)); }
public void UpdateHashPassword() { // get users var users = _userepository.GetAll(); foreach (var xUser in users) { xUser.Password = UserCommon.CreateHash(xUser.PasswordOrginal.Trim()); _userepository.Update(xUser); } _unitOfWork.CommitChanges(); }
public bool CheckUser(string user, string password) { var userS = _customUserRepository.CheckUser(user.ToLower()); if (userS == null) { return(false); } var hashedPassword = UserCommon.CreateHash(password); return(hashedPassword.Equals(userS.Password)); }
public ActionResult SignUp(UserDTO userDTO) { var db = new TableContext(); var user = UserCommon.ConvertDTOtoBO(userDTO); if (ModelState.IsValid) { TempData["submitMessage"] = "success"; db.Users.Add(user); db.SaveChanges(); } return(View()); }
public CommonDbResponse DeleteAdminUser(UserCommon model) { CommonDbResponse r = new CommonDbResponse(); // initialize api feature var sql = "Exec sproc_user_detail "; sql += " @flag='d'"; sql += ", @user_id=" + dao.FilterString(model.UserName); sql += ", @action_user = "******", @updated_ip=" + dao.FilterString(model.IpAddress); //sql += ", @actionbrowser=" + dao.FilterString(model.BrowserInfo); r = dao.ParseCommonDbResponse(sql); return(r); }
public ActionResult SignUp(UserCommon model) { if (model != null) { model.Password = EncryptionHelper.Encrypt(model.Password); model.VerificationFor = "NewAccount"; model.VerificationSuccess = "0"; string Letter = "abcdefghijklmnopqrstuvwxyz"; char[] AlphaNumeric = (Letter + Letter.ToUpper() + "1234567890!@#$%^&*").ToCharArray(); var code = ""; Random ran = new Random(); for (int i = 0; i < 6; i++) { code = code + AlphaNumeric[ran.Next(0, 71)].ToString(); } var Subject = "Verification Code"; var rootUrl = System.Configuration.ConfigurationManager.AppSettings["urlRoot"]; var Body = "Your verification Code is<br/><button style=\"background-color:rebeccapurple; padding:10px; border-radius: 12px\"><a href='" + rootUrl + "/User/Verification?Email=" + model.Email + "&VerificationCode=" + code + "' style=\"color:white;font-size:10px;\">Click Here to Verify Your Account</a></button>"; var emailResponse = SendEmail(model.Email, Subject, Body); if (emailResponse == false) { DbResponse resp = new DbResponse(); resp.ErrorCode = 1; resp.Message = "You email no doesnot found"; StaticData.SetMessageInSession(resp); return(View(model)); } model.VerificationCode = code; //Uri url = Request.Url; var response = buss.SignUp(model); if (response.ErrorCode != 0) { DbResponse resp = new DbResponse(); resp.ErrorCode = response.ErrorCode; resp.Message = response.Message; StaticData.SetMessageInSession(resp); return(View(model)); } else { StaticData.SetMessageInSession(response); } } return(RedirectToAction("SignIn")); }
public async Task <UserCommonResponse> SaveAsync(UserCommon userCommon) { try { await _userCommonRepository.AddAsync(userCommon); await _unitOfWork.CompleteAsync(); return(new UserCommonResponse(userCommon)); } catch (Exception ex) { return(new UserCommonResponse($"An error ocurred while saving the UserCommon: {ex.Message}")); } }
public ActionResult ChangePassword(int userCode, string newPassword, string currentPassword) { var user = _service.GetByKey(userCode); if (user.Password != UserCommon.CreateHash(currentPassword)) { return(Json(new { result = Constants.UnSuccess })); } user.Password = UserCommon.CreateHash(newPassword); user.ModifiedBy = user.Id; user.Modified = DateTime.Now; _service.Update(user); return(Json(new { result = Constants.Success })); }
public ActionResult SignIn() { if (Session["Action"] == null) { if (Request.UrlReferrer.LocalPath != null) { var action = Request.UrlReferrer.LocalPath; //provides the path of previous url Session["Action"] = action; } } UserCommon model = new UserCommon(); return(View(model)); }