public List<Company> GetCompaniesList(SecurityContext securityContext) { var companiesList = new List<Company>(); switch ((UserRoles)securityContext.User.RoleId) { case UserRoles.Customer: case UserRoles.Manager: case UserRoles.Salesman: companiesList = new List<Company> { new Company { CompanyId = securityContext.User.CompanyId, CompanyName = securityContext.User.CompanyName } }; break; case UserRoles.Administrator: companiesList = _companiesRepository.GetAllCompanies(); companiesList.RemoveAll(c => c.CompanyName.Equals(Constants.SolucionesARName.ToStringValue())); break; case UserRoles.SuperUser: companiesList = _companiesRepository.GetAllCompanies(); break; } return companiesList; }
public List<Canton> GetCantons(SecurityContext securityContext) { var cantonsList = new List<Canton>(); switch ((UserRoles)securityContext.User.RoleId) { case UserRoles.Customer: case UserRoles.Manager: case UserRoles.Salesman: cantonsList = new List<Canton> { new Canton { CantonId = securityContext.User.CompanyId, Name = securityContext.User.CompanyName } }; break; case UserRoles.SuperUser: case UserRoles.Administrator: cantonsList = _cantonsRepository.GetAllCantons(); break; } return cantonsList; }
public List<Rol> GetRoles(SecurityContext securityContext) { var rolesList = new List<Rol>(); switch ((UserRoles)securityContext.User.RoleId) { case UserRoles.Customer: case UserRoles.Manager: case UserRoles.Salesman: rolesList = new List<Rol> { new Rol { RolId = securityContext.User.RoleId, Name = securityContext.User.Role } }; break; case UserRoles.SuperUser: case UserRoles.Administrator: rolesList = _rolesRepository.GetAllRoles(); break; } return rolesList; }
public List<Province> GetProvinces(SecurityContext securityContext) { var provincesList = new List<Province>(); switch ((UserRoles)securityContext.User.RoleId) { case UserRoles.Customer: case UserRoles.Manager: case UserRoles.Salesman: provincesList = new List<Province> { new Province { ProvinceId = securityContext.User.CompanyId, Name = securityContext.User.CompanyName } }; break; case UserRoles.SuperUser: case UserRoles.Administrator: provincesList = _provincesRepository.GetAllProvinces(); break; } return provincesList; }
public List<IdentificationType> GetIdentificationTypes(SecurityContext securityContext) { var identificationTypesList = new List<IdentificationType>(); switch ((UserRoles)securityContext.User.RoleId) { case UserRoles.Customer: case UserRoles.Manager: case UserRoles.Salesman: break; case UserRoles.SuperUser: case UserRoles.Administrator: identificationTypesList = _identificationTypesRepository.GetAllIdentificationTypes(); break; } return identificationTypesList; }
/// <summary> /// Clears the security context. /// </summary> protected void ClearSecurityContext() { SecurityContext = null; }
/// <summary> /// Creates the security context. /// </summary> private void CreateSecurityContext() { if (SecurityContext == null) { var identity = System.Web.HttpContext.Current.User.Identity; if (identity.IsAuthenticated && !string.IsNullOrEmpty(identity.Name)) { SecurityContext = new SecurityContext { User = _usersManagement.GetUserInformation(identity.Name), }; } else { System.Web.HttpContext.Current.Session.Abandon(); FormsAuthentication.SignOut(); FormsAuthentication.RedirectToLoginPage(); } } }