public frmUser() { InitializeComponent(); DALObject = new DAL.Users.UserDAL(); UserGroupDALObj = new DAL.Users.UserGroupDAL(); FirstControl = txtUserName; }
public frmChangePassword() { InitializeComponent(); UserDALObj = new DAL.Users.UserDAL(); btnSave.Caption = "Change Password"; FirstControl = txtCurrentPassword; }
public ActionResult ApproveUser() { if (Common.Props.LoginUser == null || Common.Props.LoginUser.Role != eUserRoleID.Admin) { return(RedirectToAction("PermissionDenied", "Home")); } DAL.Users.UserDAL UserDALObj = new DAL.Users.UserDAL(); return(View(UserDALObj.GetPendingApprovalUserList())); }
public frmForgetPassword() { InitializeComponent(); FirstControl = txtUserName; UserDALObj = new DAL.Users.UserDAL(); btnSave.Caption = "Reset Password"; FirstControl = txtUserName; }
public ActionResult ApproveUser(int UserID) { if (ModelState.IsValid) { DAL.Users.UserDAL UserDALObj = new DAL.Users.UserDAL(); if (Common.Functions.SetAfterSaveResult(ModelState, UserDALObj.ApproveUser(UserID))) { return(RedirectToAction("ApproveUser")); } } return(View()); }
//string Password { get; set; } public frmUserLogin() { InitializeComponent(); AllowRefresh = false; SaveButtonCaption = "Login"; //ExitButtonCaption = "Cancel"; UserDAL = new DAL.Users.UserDAL(); UserGroupDALObj = new DAL.Users.UserGroupDAL(); FirstControl = txtUserName; }
public ActionResult ChangePassword(ChangePasswordViewModel ViewModel) { if (ModelState.IsValid) { DAL.Users.UserDAL UserDALObj = new DAL.Users.UserDAL(); if (Common.Functions.SetAfterSaveResult(ModelState, UserDALObj.ChangePassword(Common.Props.LoginUser.UserID, ViewModel.NewPassword))) { return(RedirectToAction("Manage")); } } return(View(ViewModel)); }
//public async Task SendApprovalEmailToAdmins(int UserID) public void SendApprovalEmailToAdmins(int UserID) { try { CustomerViewModel Customer = DALObj.FindByIDGetListViewModel(UserID); DAL.Users.UserDAL UserDALObj = new DAL.Users.UserDAL(); List <Models.Users.UserAdminListViewModel> Admins = UserDALObj.GetAdminUsers(); string Subject = "Activate " + Customer.BusinessName ?? "NoNames" + "'s account."; string MessageBody = string.Format(@"Hello, A new customer recently registered on {0} Here is the details. Business Name : {1} Contact Name : {2} Address : {3} City : {4} Country : {5} Please verify his/her account by clicking on the below link {6} If the above link is not working then please copy and paste it in your browser's address bar. If this email is not relevant to you then please go to contact page on {0} and contact authority to stop sending emails to you.", Common.Props.CurrentDomainName, Customer.BusinessName, Customer.ContactName, Customer.Address ?? "", Customer.City ?? "" + " " + Customer.Postcode ?? "", Customer.Country, Common.Props.CurrentDomainName + @"/Customer/ApproveCustomer/" + UserID.ToString()); string SendToIds = ""; foreach (Models.Users.UserAdminListViewModel admin in Admins) { SendToIds += (SendToIds != "" ? "," : "") + admin.EMailID; } Common.Functions.SendEmailFromNoReply(SendToIds, Subject, MessageBody); //Common.Functions.SendEmailFromNoReply(SendToIds, Subject, MessageBody); } catch (Exception ex) { ViewBag.ErrorMsg = ex.Message; RedirectToAction("Error"); } }
public ActionResult Register(UserRegistrationViewModel ViewModel) { if (ModelState.IsValid) { DAL.Users.UserDAL UDAL = new DAL.Users.UserDAL(); if (Common.Functions.SetAfterSaveResult(ModelState, UDAL.SaveRecord(ViewModel))) { // Successfully Saved. //return RedirectToAction("Index","Home"); return(RedirectToAction("Register", "Users")); } } return(View(ViewModel)); }
public ActionResult Login(UserLoginViewModel ViewModel, string returnUrl) { if (ModelState.IsValid) { DAL.Users.UserDAL UserDALObj = new DAL.Users.UserDAL(); //var user = await UserManager.FindAsync(model.UserName, model.Password); UserLoginDetails User = UserDALObj.MatchUserCredentials(ViewModel.EmailID, ViewModel.Password); //Membership.ValidateUser(model.UserName, model.Password); if (User != null) { if (User.IsApproved == null) { ModelState.AddModelError("", "Your account approval is still pending. Please contact to your admin for instant approval."); } else if (!User.IsApproved.Value) { ModelState.AddModelError("", "Your account hase been rejected. Please contact customer support for more information."); } else { Common.Props.LoginUser = User; JavaScriptSerializer js = new JavaScriptSerializer(); string data = js.Serialize(User); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, User.FullName, DateTime.Now, DateTime.Now.AddMonths(1), ViewModel.RememberMe, data); string encToken = FormsAuthentication.Encrypt(ticket); HttpCookie authoCookies = new HttpCookie(FormsAuthentication.FormsCookieName, encToken); Response.Cookies.Add(authoCookies); //await SignInAsync(user, model.RememberMe); if (Url.IsLocalUrl(returnUrl)) { return(Redirect(returnUrl)); } else { return(RedirectToAction("Index", "Home")); } } } else { ModelState.AddModelError("", "Invalid username or password."); } } // If we got this far, something failed, redisplay form ModelState.Remove("Password"); return(View(ViewModel)); }