public webModel.SearchResult SearchStores(coreModel.SearchCriteria criteria) { var retVal = new webModel.SearchResult(); //Filter resulting stores correspond to current user permissions //first check global permission if (!_securityService.UserHasAnyPermission(User.Identity.Name, null, StorePredefinedPermissions.Read)) { //Get user 'read' permission scopes criteria.StoreIds = _securityService.GetUserPermissions(User.Identity.Name) .Where(x => x.Id.StartsWith(StorePredefinedPermissions.Read)) .SelectMany(x => x.AssignedScopes) .OfType <StoreSelectedScope>() .Select(x => x.Scope) .ToArray(); //Do not return all stores if user don't have corresponding permission if (criteria.StoreIds.IsNullOrEmpty()) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } } var result = _storeService.SearchStores(criteria); retVal.TotalCount = result.TotalCount; retVal.Stores = result.Stores.ToArray(); return(retVal); }
public webModel.SearchResult SearchStores(coreModel.SearchCriteria criteria) { //Filter resulting stores correspond to current user permissions //first check global permission if (!_securityService.UserHasAnyPermission(User.Identity.Name, null, StorePredefinedPermissions.Read)) { //Get user 'read' permission scopes criteria.StoreIds = _securityService.GetUserPermissions(User.Identity.Name) .Where(x => x.Id.StartsWith(StorePredefinedPermissions.Read)) .SelectMany(x => x.AssignedScopes) .OfType<StoreSelectedScope>() .Select(x => x.Scope) .ToArray(); } var result = _storeService.SearchStores(criteria); var retVal = new webModel.SearchResult { TotalCount = result.TotalCount, Stores = result.Stores.Select(x => x.ToWebModel()).ToArray() }; return retVal; }
public webModel.SearchResult SearchStores(coreModel.SearchCriteria criteria) { //Filter resulting stores correspond to current user permissions //first check global permission if (!_securityService.UserHasAnyPermission(User.Identity.Name, null, StorePredefinedPermissions.Read)) { //Get user 'read' permission scopes criteria.StoreIds = _securityService.GetUserPermissions(User.Identity.Name) .Where(x => x.Id.StartsWith(StorePredefinedPermissions.Read)) .SelectMany(x => x.AssignedScopes) .OfType <StoreSelectedScope>() .Select(x => x.Scope) .ToArray(); } var result = _storeService.SearchStores(criteria); var retVal = new webModel.SearchResult { TotalCount = result.TotalCount, Stores = result.Stores.Select(x => x.ToWebModel()).ToArray() }; return(retVal); }