public UserManagementController(IUserManagementRepository userManagementRepository, ILookupServiceRepository lookupServiceRepository) { this._lookupServiceRepository = lookupServiceRepository; this._lookupServiceRepository.ServiceHeaders = PresentationUtility.GetBasicHeaders(new string[] { pmsVariable.ServiceHeaderKey.EmployeeId, pmsVariable.ServiceHeaderKey.UserName, pmsVariable.ServiceHeaderKey.Email }); this._userManagementRepository = userManagementRepository; this._userManagementRepository.ServiceHeaders = PresentationUtility.GetBasicHeaders(new string[] { pmsVariable.ServiceHeaderKey.EmployeeId, pmsVariable.ServiceHeaderKey.UserName, pmsVariable.ServiceHeaderKey.Email }); }
public ActionResult Notification(string id) { PmsNotification notification = PresentationUtility.GetNotification(id); ViewBag.Heading = notification.Title; ViewBag.Detail = notification.Detail; return(View()); }
public ActionResult Search(string id, string email, string firstName, string lastName) { int pageSize = 10; int pageNumber = 1; this._userManagementRepository.ServiceHeaders = PresentationUtility.GetBasicHeaders(new string[] { pmsVariable.ServiceHeaderKey.EmployeeId, pmsVariable.ServiceHeaderKey.UserName, pmsVariable.ServiceHeaderKey.Email }); IList <IPerson> modelUsers = null; modelUsers = this._userManagementRepository.PersonSearch(id, email, firstName, lastName); TempData["Model"] = modelUsers; return(View(modelUsers.ToPagedList(pageNumber, pageSize))); }
public ActionResult Login(LoginModel model, string returnUrl) { if (ModelState.IsValid) { if (Membership.ValidateUser(model.UserName, model.Password)) { using (DirectoryEntry de = new DirectoryEntry(ConfigurationManager.ConnectionStrings[ConfigurationKey.ActiveDirectoryConnectionString].ToString(), model.UserName, model.Password)) { using (DirectorySearcher adSearch = new DirectorySearcher(de)) { const string _filterFormat = "(sAMAccountName={0})"; adSearch.Filter = string.Format(_filterFormat, model.UserName); SearchResult adSearchResult = adSearch.FindOne(); if (adSearchResult.Properties.Count != 0) { const string _employeeIdkey = "employeeid"; const string _emailkey = "userprincipalname"; model.EmployeeId = adSearchResult.Properties[_employeeIdkey][0].ToString(); model.Email = adSearchResult.Properties[_emailkey][0].ToString(); Session[SessioKey.LoginCredential] = model; if (model.Email == null || string.IsNullOrEmpty(model.Email)) { ModelState.AddModelError(string.Empty, Resources.Pms.Login_InvalidLogin); } else { IList <CodeMessage> messages = new List <CodeMessage>(); this._userManagementRepository.ServiceHeaders = PresentationUtility.GetBasicHeaders(new string[] { ServiceHeaderKey.EmployeeId, ServiceHeaderKey.UserName, ServiceHeaderKey.Email }); IEmployee employee = _userManagementRepository.EmployeeGet(SearchKey.Email, model.Email, out messages); if (employee == null) { Session[SessioKey.LoginCredential] = null; foreach (CodeMessage message in messages) { ModelState.AddModelError(string.Empty, message.Name); } return(View(model)); } else { model.PersonId = employee.PersonId; model.EmployeeId = employee.EmployeeId; model.AccountState = string.IsNullOrEmpty(employee.PersonObject.PersonStatus) ? 1 : Int16.Parse(employee.PersonObject.PersonStatus); Session[SessioKey.LoginCredential] = model; FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); } } } } } if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith(@"\//")) { return(Redirect(returnUrl)); } else { return(RedirectToAction(ControllerActionString.Index, ControllerString.Home)); } } else { ModelState.AddModelError(string.Empty, Resources.Pms.Login_InvalidLogin); } } return(View(model)); }