public ActionResult Active(ActiveModels model, string captch) { if (string.IsNullOrWhiteSpace(captch)) { model.ErrMessages = "Nhập đúng mã xác thực."; return(View(model)); } bool cv = CaptchaController.IsValidCaptchaValue(captch); if (!cv) { model.ErrMessages = "Nhập đúng mã xác thực."; return(View(model)); } try { if (string.IsNullOrWhiteSpace(model.username)) { model.ErrMessages = "Không tồn tại tài khoản trong hệ thống."; return(View(model)); } if (model.username != System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(model.code))) { model.ErrMessages = "Không tồn tại tài khoản trong hệ thống."; return(View(model)); } Company currentComp = ((EInvoiceContext)FXContext.Current).CurrentCompany; IRBACMembershipProvider _MemberShipProvider = IoC.Resolve <IRBACMembershipProvider>(); if (_MemberShipProvider.GetUser(model.username, true) != null) { model.ErrMessages = "Tài khoản đã được kích hoạt trước đó, liên hệ để được hỗ trợ."; return(View("Active", model)); } if (!model.password.Equals(model.comfirmpassword)) { model.ErrMessages = "Nhập đúng mật khẩu xác thực."; return(View("Active", model)); } string status = ""; user tmp = _MemberShipProvider.CreateUser(model.username, model.password, currentComp.Email, null, null, true, null, currentComp.id.ToString(), out status); if (status != "Success" || tmp == null) { model.ErrMessages = "Chưa kích hoạt được tài khoản, liên hệ để được hỗ trợ."; return(View("Active", model)); } IRBACRoleProvider _RoleProvider = IoC.Resolve <IRBACRoleProvider>(); if (_RoleProvider.RoleExists("Admin")) { _RoleProvider.UpdateUsersToRoles(tmp.userid, new string[] { "Admin" }); } return(Redirect("/Account/Logon")); } catch (Exception ex) { log.Error(ex); model.ErrMessages = "Chưa kích hoạt được tài khoản, liên hệ để được hỗ trợ."; return(View()); } }
public void LoadActiveToDoForSelectedDate(DateTime selectedDate) { ActiveModels.ReplaceRangeWithoutUpdating( GetToDoModelsByCondition(x => x.Status == ToDoStatus.Active && x.WhenHappens.Year == selectedDate.Year && x.WhenHappens.Month == selectedDate.Month && x.WhenHappens.Day == selectedDate.Day)); ActiveModels.RaiseCollectionChanged(); }
public ActionResult Active() { Company currentComp = ((EInvoiceContext)FXContext.Current).CurrentCompany; ActiveModels model = new ActiveModels(); string code = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(currentComp.AccountName)); string username = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(code)); model.code = code; model.username = username; model.ErrMessages = ""; return(View(model)); }
public ActionResult HandleActive(ActiveModels active) { if (ModelState.IsValid) { var activeResult = AccountService.Active(active.Token); if (activeResult == "invalid") { ModelState.AddModelError("Token", "Mã kích hoạt tài khoản không đúng."); return(View("Account.Active", active)); } if (activeResult == "expire") { var getTokenUrl = string.Format("{0}account/gettoken", ConfigHelper.WebDomain); ModelState.AddModelError("Token", string.Format("Mã kích hoạt tài khoản đã hết hạn. Click vào <a style='color: #007FF0' href='{0}' title='Kích hoạt tài khoản'> đây</a> để lấy mã kích hoạt. ", getTokenUrl)); return(View("Account.Active", active)); } return(RedirectToAction("Login")); } return(View("Account.Active", active)); }