コード例 #1
0
        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;
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        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;
        }
コード例 #6
0
 /// <summary>
 /// Clears the security context.
 /// </summary>
 protected void ClearSecurityContext()
 {
     SecurityContext = null;
 }
コード例 #7
0
 /// <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();
         }
     }
 }