コード例 #1
0
        public IEnumerable <vwBranch> FetchDrugStore(string CityId, string DistrictId)
        {
            BranchRepository branchRepository = new BranchRepository(new ErpStaffDbContext());
            UserRepository   userRepository   = new UserRepository(new ErpDbContext());
            List <vwBranch>  locationList     = branchRepository.GetAllvwBranch().ToList();
            var user = userRepository.GetByvwUserName(Helpers.Common.CurrentUser.UserName);

            if (!string.IsNullOrEmpty(CityId))
            {
                locationList = locationList.Where(x => x.CityId == CityId).ToList();
            }
            if (!string.IsNullOrEmpty(DistrictId))
            {
                locationList = locationList.Where(x => x.DistrictId == DistrictId).ToList();
            }

            if (!Erp.BackOffice.Filters.SecurityFilter.IsAdmin() && !Erp.BackOffice.Filters.SecurityFilter.IsKeToan())
            {
                locationList = locationList.Where(x => ("," + user.DrugStore + ",").Contains("," + x.Id + ",") == true).ToList();
            }
            return(locationList);
        }