public ActionResult UserGridViewPartialDelete(System.Int32 BusinessEntityId) { if (BusinessEntityId >= 0) { try { if (!UserHasDependentData(BusinessEntityId)) { BusinessLogicLayer.Entity.Persons.Person person = new BusinessLogicLayer.Entity.Persons.Person(BusinessEntityId); if (person.HasObject) { person.CurrentCredential.Delete(); person.Delete(); } } else { ViewData["EditError"] = Resources.MainResource.UserHasDependentData; } // Insert here a code to delete the item from your model } catch (Exception e) { ViewData["EditError"] = e.Message; } } var model = new BusinessLogicLayer.Components.Persons.PersonLogic().GetAll(); return(PartialView("_UserGridViewPartial", model)); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new BusinessLogicLayer.Entity.Persons.Person { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
private void xrTableCellSupervisor_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) { XRTableCell cell = sender as XRTableCell; if (string.IsNullOrEmpty(cell.Text)) { cell.Text = ""; return; } BusinessLogicLayer.Entity.PPM.RequestWithdraw withdraw = new BusinessLogicLayer.Entity.PPM.RequestWithdraw(Convert.ToInt32(cell.Text)); if (!withdraw.CreatedBy.HasValue || withdraw.CreatedBy.Value == 0) { cell.Text = Supervisor; } else { BusinessLogicLayer.Entity.Persons.Person p = new BusinessLogicLayer.Entity.Persons.Person(withdraw.CreatedBy.Value); if (p.HasObject) { cell.Text = p.DisplayName; } else { cell.Text = Supervisor; } } }
private bool EmailExists(string email, int id) { var currentUser = new BusinessLogicLayer.Entity.Persons.Person(id); var checkUser = new BusinessLogicLayer.Components.Persons.PersonLogic().GetByEmail(email); if (checkUser == null) { return(false); } if (!currentUser.HasObject && checkUser != null) { return(true); } else if (currentUser.HasObject && checkUser != null && currentUser.BusinessEntityId != checkUser.BusinessEntityId) { return(true); } return(false); }
public Task <TUser> FindAsync(UserLoginInfo login) { if (login == null) { throw new ArgumentNullException("login"); } var userId = userLoginProviderLogic.GetUserIdByLogin(login); if (userId != null) { TUser user = new BusinessLogicLayer.Entity.Persons.Person(Convert.ToInt32(userId)) as TUser; if (user != null) { return(Task.FromResult <TUser>(user)); } } return(Task.FromResult <TUser>(null)); }
public async Task <ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl) { if (User.Identity.IsAuthenticated) { return(RedirectToAction("Index", "Manage")); } if (ModelState.IsValid) { // Get the information about the user from the external login provider var info = await AuthenticationManager.GetExternalLoginInfoAsync(); if (info == null) { return(View("ExternalLoginFailure")); } var user = new BusinessLogicLayer.Entity.Persons.Person { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user); if (result.Succeeded) { result = await UserManager.AddLoginAsync(user.Id, info.Login); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); return(RedirectToLocal(returnUrl)); } } AddErrors(result); } ViewBag.ReturnUrl = returnUrl; return(View(model)); }
public ActionResult UserGridViewPartialAddNew([ModelBinder(typeof(DevExpressEditorsBinder))] Qiyas.BusinessLogicLayer.Entity.Persons.Person item) { if (ModelState.IsValid) { string firstName = ""; string middleName = ""; string lastName = ""; GetFullNameFromDisplayName(item.DisplayName, out firstName, out middleName, out lastName); var user = new BusinessLogicLayer.Entity.Persons.Person { UserName = item.UserName, Email = item.Email, IsActive = item.IsActive, DisplayName = item.DisplayName.Trim(), FirstName = firstName, MiddleName = middleName, LastName = lastName, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now }; try { // Insert here a code to insert the new item in your model bool usernameExists = UserNameExists(item.UserName, 0); bool emailExists = EmailExists(item.Email, 0); if (!usernameExists && !emailExists) { var result = UserManager.Create <BusinessLogicLayer.Entity.Persons.Person, string>(user, item.Password); if (result.Succeeded) { } else { string msgError = ""; foreach (var error in result.Errors) { if (error.Contains("Passwords")) { msgError = Resources.MainResource.PasswordCheckError + " "; } else { msgError += error + " "; } } ViewData["EditError"] = msgError; } } else if (usernameExists) { ViewData["EditError"] = Resources.MainResource.UserNameExists; } else if (emailExists) { ViewData["EditError"] = Resources.MainResource.EmailExists; } } catch (Exception e) { if (e.Message.Contains("null") && e.Message.Contains("password")) { ViewData["EditError"] = Resources.MainResource.RequiredPassword; } else { ViewData["EditError"] = e.Message; } } } else { string msgError = ""; foreach (ModelState modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { msgError += error.ErrorMessage + " "; } } ViewData["EditError"] = msgError; } var model = new BusinessLogicLayer.Components.Persons.PersonLogic().GetAll(); return(PartialView("_UserGridViewPartial", model)); }
public ActionResult UserGridViewPartialUpdate([ModelBinder(typeof(DevExpressEditorsBinder))] Qiyas.BusinessLogicLayer.Entity.Persons.Person item) { if (ModelState.IsValid) { string firstName = ""; string middleName = ""; string lastName = ""; GetFullNameFromDisplayName(item.DisplayName, out firstName, out middleName, out lastName); var user = new BusinessLogicLayer.Entity.Persons.Person(item.BusinessEntityId); if (user != null) { user.UserName = item.UserName; user.Email = item.Email; user.IsActive = item.IsActive; user.DisplayName = item.DisplayName.Trim(); user.FirstName = firstName; user.MiddleName = middleName; user.LastName = lastName; user.ModifiedDate = DateTime.Now; try { // Insert here a code to insert the new item in your model bool usernameExists = UserNameExists(item.UserName, user.BusinessEntityId); bool emailExists = EmailExists(item.Email, user.BusinessEntityId); if (!usernameExists && !emailExists) { bool result = user.Save(); if (!user.CurrentCredential.IsNew) { user.CurrentCredential.Save(); } if (result) { if (!string.IsNullOrEmpty(item.Password)) { string code = UserManager.GeneratePasswordResetToken(user.Id); var passresult = UserManager.ResetPassword(user.Id, code, item.Password); if (passresult.Succeeded) { } else { string msgError = ""; foreach (var error in passresult.Errors) { if (error.Contains("Passwords")) { msgError = Resources.MainResource.PasswordCheckError + " "; } else { msgError += error + " "; } } ViewData["EditError"] = msgError; } } } } else if (usernameExists) { ViewData["EditError"] = Resources.MainResource.UserNameExists; } else if (emailExists) { ViewData["EditError"] = Resources.MainResource.EmailExists; } } catch (Exception e) { if (e.Message.Contains("null") && e.Message.Contains("password")) { ViewData["EditError"] = Resources.MainResource.RequiredPassword; } else { ViewData["EditError"] = e.Message; } } } else { ViewData["EditError"] = Resources.MainResource.NoUserError; } } else { string msgError = ""; foreach (ModelState modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { msgError += error.ErrorMessage + " "; } } ViewData["EditError"] = msgError; } var model = new BusinessLogicLayer.Components.Persons.PersonLogic().GetAll(); return(PartialView("_UserGridViewPartial", model)); }