//static void Main(string[] args) //{ // //GameOfLifeSource golSrc = new GameOfLifeSource(1680, 1050); // GameOfLifeSource golSrc = new GameOfLifeSource(840, 525); // 1680 x 1050 / 2 // //GameOfLifeSource golSrc = new GameOfLifeSource(560, 350); // 1680 x 1050 / 3 // //GameOfLifeSource golSrc = new GameOfLifeSource(336, 210); // 1680 x 1050 / 5 // GenericDelay<Image> delayFilt = new GenericDelay<Image>(new TimeSpan(0, 0, 0, 0, 100)); // //WallpaperFilter wpFilt = new WallpaperFilter(); // DisplayFilter displayFilt = new DisplayFilter(); // golSrc.OutputPin.AttachTo(delayFilt.InputPin); // delayFilt.OutputPin.AttachTo(displayFilt.InputPin); // displayFilt.OutputPin.AttachTo(golSrc.InputPin); // PinOut<Image> golSrcOut = new PinOut<Image>(); // golSrcOut.AttachTo(golSrc.InputPin); // golSrcOut.Send(null); // //golSrcOut.Send(null); // //golSrcOut.Send(null); // //golSrcOut.Send(null); // Console.ReadLine(); //} static void Main(string[] args) { RedditSource redditSource = new RedditSource("http://www.reddit.com/r/pics/.json"); GenericFilter<Image> sizeFilt = new GenericFilter<Image>(img => 100 < img.Width && img.Width < 1000 && 100 < img.Height && img.Height < 800); BorderFilter brdInnerFilt = new BorderFilter(Color.Black, 1); BorderFilter brdOuterFilt = new BorderFilter(Color.White, 9); RotateFilter rotFilt = new RotateFilter(-30, 30); CanvasFilter cvsFilt = new CanvasFilter(); GenericDelay<Image> delayFilt = new GenericDelay<Image>(new TimeSpan(0, 0, 30)); WallpaperFilter wpFilt = new WallpaperFilter(); redditSource.OutputPin.AttachTo(sizeFilt.InputPin); sizeFilt.SuccessPin.AttachTo(brdInnerFilt.InputPin); sizeFilt.FailurePin.AttachTo(redditSource.InputPin); brdInnerFilt.OutputPin.AttachTo(brdOuterFilt.InputPin); brdOuterFilt.OutputPin.AttachTo(rotFilt.InputPin); rotFilt.OutputPin.AttachTo(cvsFilt.PictureInputPin); cvsFilt.OutputPin.AttachTo(delayFilt.InputPin); cvsFilt.OutputPin.AttachTo(cvsFilt.CanvasInputPin); delayFilt.OutputPin.AttachTo(wpFilt.InputPin); wpFilt.OutputPin.AttachTo(redditSource.InputPin); /* prime canvas */ PinOut<Image> canvasOut = new PinOut<Image>(); canvasOut.AttachTo(cvsFilt.CanvasInputPin); Image canvas; try { int bytesRead; byte[] buf = new byte[1024]; FileStream fs = new FileStream(Path.Combine(Environment.CurrentDirectory, "wall.bmp"), FileMode.Open); MemoryStream ms = new MemoryStream(); while ((bytesRead = fs.Read(buf, 0, 1024)) > 0) ms.Write(buf, 0, bytesRead); ms.Seek(0, SeekOrigin.Begin); fs.Close(); canvas = Image.FromStream(ms); } catch (FileNotFoundException) { Size monitorSize = SystemInformation.PrimaryMonitorSize; canvas = new Bitmap(monitorSize.Width, monitorSize.Height); } canvasOut.Send(canvas); PinOut<Image> ljSrcOut = new PinOut<Image>(); ljSrcOut.AttachTo(redditSource.InputPin); ljSrcOut.Send(null); /* only need a signal to kick off the source */ ljSrcOut.Send(null); /* put two images in the loop to test multithreading */ //ljSrcOut.Send(null); /* hell, why not three? */ //ljSrcOut.Send(null); /* we are approaching levels of insanity heretofore untold */ Console.ReadLine(); }
public async Task<HttpResponseMessage> GetByName(string name, int pageNumber, int pageSize) { try { GenericFilter filter = new GenericFilter(pageNumber, pageSize); IEnumerable<GameModel> result = Mapper.Map<IEnumerable<GameModel>>(await GamesService.GetRangeAsync(name, filter)); if (result != null) return Request.CreateResponse(HttpStatusCode.OK, result); else return Request.CreateResponse(HttpStatusCode.NotFound); } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); } }
/// <summary> /// Get collection of topics /// </summary> /// <param name="filter">Filter</param> /// <returns>Collection of topics</returns> public async Task<ICollection<Model.Common.ITopic>> GetRangeAsync(GameStore.Common.GenericFilter filter) { try { if (filter == null) filter = new GenericFilter(1, 5); return Mapper.Map<ICollection<ITopic>>(await repository.Where<TopicEntity>() .OrderBy(t => t.Title) .Skip((filter.PageNumber * filter.PageSize) - filter.PageSize) .Take(filter.PageSize).ToListAsync()); } catch (Exception ex) { throw ex; } }
/// <summary> /// Get by name, where games are not in cart /// </summary> /// <param name="name">Part of name to search by</param> /// <param name="filter">Filter options</param> /// <returns>IEnumerable of Igame</returns> public async Task<IEnumerable<IGame>> GetRangeAsync(string name, GenericFilter filter) { try { if (filter == null) filter = new GenericFilter(1, 5); return Mapper.Map<IEnumerable<IGame>>(await repository.Where<GameEntity>() .Where(g => g.IsInCart == false && g.Name.Contains(name)) .OrderBy(g => g.Name) .Skip((filter.PageNumber * filter.PageSize) - filter.PageSize) .Take(filter.PageSize).ToListAsync()); } catch (Exception ex) { throw ex; } }
/// <summary> /// Get collection of game images /// </summary> /// <param name="filter">Filter, which provides options for pagination</param> /// <returns>GameImages collection</returns> public async Task<IEnumerable<Model.Common.IGameImage>> GetRangeAsync(GenericFilter filter) { try { if (filter == null) filter = new GenericFilter(1, 5); return Mapper.Map<IEnumerable<IGameImage>>(await repository.Where<GameImageEntity>() .OrderBy(g => g.Id) .Skip((filter.PageNumber * filter.PageSize) - filter.PageSize) .Take(filter.PageSize).ToListAsync()); } catch (Exception) { throw; } }
public async Task<HttpResponseMessage> Get(Guid GameId, int pageNumber, int pageSize) { try { GenericFilter filter = new GenericFilter(pageNumber, pageSize); IEnumerable<ReviewModel> result = AutoMapper.Mapper.Map<IEnumerable<ReviewModel>>(await service.GetAsync(GameId, filter)); if (result == null) return Request.CreateResponse(HttpStatusCode.OK, "No result."); else return Request.CreateResponse(HttpStatusCode.OK, result); } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); } }
/// <summary> /// Get collection of reviews that belong to game /// </summary> /// <param name="gameId">game FK</param> /// <param name="filter">filter option</param> /// <returns>Collection of games</returns> public async Task<IEnumerable<IReview>> GetAsync(Guid gameId, GameStore.Common.GenericFilter filter) { try { if (filter == null) filter = new GenericFilter(1, 5); return Mapper.Map<IEnumerable<IReview>>(await repository.Where<ReviewEntity>() .Where(g => g.GameId == gameId) .OrderBy(g => g.Score) .Skip((filter.PageNumber * filter.PageSize) - filter.PageSize) .Take(filter.PageSize).ToListAsync()); } catch (Exception) { throw; } }
/// <summary> /// Get collection of orders that belong to user /// </summary> /// <param name="userId">User FK</param> /// <param name="filter">Fitler options</param> /// <returns>Collection of orders</returns> public async Task<ICollection<Model.Common.IOrder>> GetRangeAsync(string userId, GenericFilter filter) { try { if (filter == null) filter = new GenericFilter(1, 5); return Mapper.Map<ICollection<IOrder>>(await repository.Where<OrderEntity>() .Where(c => c.UserId == userId) .OrderBy(c => c.Surname) .Skip((filter.PageNumber * filter.PageSize) - filter.PageSize) .Take(filter.PageSize).ToListAsync()); } catch (Exception ex) { throw ex; } }
/// <summary> /// Get comments that belong to post /// </summary> /// <param name="postId">Post Fk</param> /// <param name="filter">Filter options</param> /// <returns>Collection of comments</returns> public async Task<IEnumerable<IComment>> GetRangeAsync(Guid postId, GenericFilter filter) { try { if (filter == null) filter = new GenericFilter(1, 5); return Mapper.Map<IEnumerable<IComment>>(await repository.Where<CommentEntity>() .Where(c => c.PostId == postId) .OrderByDescending(p => p.Date) .Skip((filter.PageNumber * filter.PageSize) - filter.PageSize) .Take(filter.PageSize).ToListAsync()); } catch (Exception ex) { throw ex; } }
public async Task<HttpResponseMessage> Get(Guid gameId, int pageNumber, int pageSize) { try { if(pageSize <= 0 || pageNumber <= 0) { pageNumber = 1; pageSize = 1; } GenericFilter filter = new GenericFilter(pageNumber, pageSize); IEnumerable<GameImageModel> result = AutoMapper.Mapper.Map<IEnumerable<GameImageModel>>(await service.GetRangeAsync(gameId, filter)); return Request.CreateResponse(HttpStatusCode.OK, result); } catch ( Exception ex) { return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); } }
public async Task<HttpResponseMessage> GetByName(string name, int pageNumber, int pageSize) { try { if(pageSize < 1 || pageNumber < 1) { pageNumber = 1; pageSize = 1; } GenericFilter filter = new GenericFilter(pageNumber, pageSize); IEnumerable<IPublisher> result = await PublisherService.GetRangeAsync(name, filter); if (result != null) return Request.CreateResponse(HttpStatusCode.OK, Mapper.Map<IEnumerable<PublisherModel>>(result)); else return Request.CreateResponse(HttpStatusCode.NotFound); } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.BadGateway, ex.Message); } }
public async Task<HttpResponseMessage> Get(int pageNumber, int pageSize) { try { if (pageNumber < 1 || pageSize < 1) { pageSize = 1; pageNumber = 1; } GenericFilter filter = new GenericFilter(pageNumber, pageSize); ICollection<TopicModel> result = Mapper.Map<ICollection<TopicModel>>(await service.GetRangeAsync(filter)); return Request.CreateResponse(HttpStatusCode.OK, result); } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); } }
public async Task<HttpResponseMessage> Get(Guid postId, int pageNumber, int pageSize) { try { if (pageSize < 1 || pageNumber < 1) { pageNumber = 1; pageSize = 1; } GenericFilter filter = new GenericFilter(pageNumber, pageSize); IEnumerable<CommentModel> result = Mapper.Map<IEnumerable<CommentModel>>(await service.GetRangeAsync(postId, filter)); if (result != null) return Request.CreateResponse(HttpStatusCode.Created, result); else return Request.CreateResponse(HttpStatusCode.BadRequest); } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); } }
/// <summary> /// Get all /// </summary> public async Task<IEnumerable<Model.Common.IPublisher>> GetRangeAsync(GenericFilter filter = null) { try { if (filter != null) { return Mapper.Map<IEnumerable<IPublisher>>( await repository.Where<PublisherEntity>() .OrderBy(u => u.Name) .Skip((filter.PageNumber * filter.PageSize) - filter.PageSize) .Take(filter.PageSize).ToListAsync()); } else return Mapper.Map<IEnumerable<IPublisher>>(await repository.GetRangeAsync<PublisherEntity>()); } catch (Exception ex) { throw ex; } }
private static BinaryExpression GetExpression <T, U>(ParameterExpression param, GenericFilter filter1, GenericFilter filter2, params string[] nestedProperty) { Expression bin1 = GetExpression <T, U>(param, filter1, nestedProperty); Expression bin2 = GetExpression <T, U>(param, filter2, nestedProperty); return(Expression.AndAlso(bin1, bin2)); }
private static Expression GetExpression <T>(ParameterExpression param, GenericFilter filter) { #region oldCode var pro = typeof(T).GetProperty(filter.PropertyName); var propertyType = pro.PropertyType; MemberExpression member = Expression.MakeMemberAccess(param, pro); // var constant = Expression.Convert(Expression.Constant(filter.Value), propertyType); #endregion #region newCode //var fieldAccess = Expression.PropertyOrField(param, filter.PropertyName); //var value = Expression.Constant(filter.Value, filter.Value.GetType()); //var constant = value.Type != fieldAccess.Type ? // (Expression)Expression.Convert(value, fieldAccess.Type) : // (Expression)value; #endregion #region olderCode Expression constant; //var targetType = TypeEx.IsNullableType(pro.PropertyType) ? Nullable.GetUnderlyingType(pro.PropertyType) : pro.PropertyType; if (TypeEx.IsNullableType(propertyType)) { constant = Expression.Convert(Expression.Constant(filter.Value), propertyType); } else { var propertyVal = Convert.ChangeType(filter.Value, propertyType); constant = Expression.Constant(propertyVal) as ConstantExpression; } // var constanta = Expression.Convert(Expression.Constant(filter.Value), propertyType); // var propertyVal = Convert.ChangeType(filter.Value, propertyType); // ConstantExpression constant = Expression.Constant(propertyVal); #endregion #region Switches switch (filter.Operation) { case Op.Equals: return(Expression.Equal(member, constant)); case Op.GreaterThan: return(Expression.GreaterThan(member, constant)); case Op.GreaterThanOrEqual: return(Expression.GreaterThanOrEqual(member, constant)); case Op.LessThan: return(Expression.LessThan(member, constant)); case Op.LessThanOrEqual: return(Expression.LessThanOrEqual(member, constant)); case Op.Contains: return(Expression.Call(member, containsMethod, constant)); case Op.StartsWith: return(Expression.Call(member, startsWithMethod, constant)); case Op.EndsWith: return(Expression.Call(member, endsWithMethod, constant)); case Op.NotEqual: return(Expression.NotEqual(member, constant)); } #endregion return(null); }
public void Filter_by_Specification() { /* 제품의 데이터를 조직하고 조건에 맞는 제품을 필터링하는 * 상세 비즈니스 로직을 통해 다음의 시나리오를 만족한다. * * */ /* 시나리오: * 개발자 A 는 사업부로 부터 다음의 개발 요청을 접수하였다. * * 상품에는 "가격", "출판사", "판매 권수", "수익률" 이 있습니다. * 저희 사업부는 위의 네 가지 기준 이외에도 추가적인 조건을 걸 수 있는 * 검색 화면을 기획하여 이를 개발 요청을 드립니다. * * 해석: * Product 클래스는 위의 4 가지 외 1 개 필드를 더 가지고 있다. * 웹에서 개발하고 있으므로 추가 패턴은 작성하여 추가하면 그만이다. * * 가격 정보는 수치(numeric)이므로 <, <= ,>=, == 등에 대한 연산이 필요하다. * 문자열 정보는 단순 매칭이므로 문자열 비교 == 만 사용하면 된다. * 수익율은 double 혹은 float 이므로 별도의 로직이 필요할 것으로 생각된다. * * */ Product[] goods = new Product[] { new Product { Name = "행복은 자아성취감", Color = Color.Blue, Size = Size.Large, Price = 54000 }, new Product { Name = "짧은 글의 행복", Color = Color.Red, Size = Size.Small, Price = 12000 }, new Product { Name = "변화하기, 변화관리", Color = Color.Green, Size = Size.Medium, Price = 32000 }, }; // Product 의 가격이 20000 원 초과이고 // 색깔이 Blue 인 책을 출력해주세요 var filter = new GenericFilter <Product>(); foreach (var item in filter.Filter(goods, new ColorSpec(Color.Blue).And(new GreaterThanSpec(20000)))) { WriteLine(item.Name); // Expected -> output: "행복은 자아성취감" Assert.AreSame(goods[0], item); // Expected -> True } foreach (var item in filter.Filter(goods, new PredicateSpec((t) => t.Color == Color.Green && t.Price > 30000 && t.Price < 40000))) { WriteLine(item.Name); // Expected -> output: "변화하기, 변화관리" Assert.AreSame(goods[2], item); // Expected -> True } }
/// <summary> /// Gets filtered food item async /// </summary> /// <param name="filter"></param> /// <returns></returns> public async Task <FoodItem> GetFoodItemAsync(GenericFilter filter) { return(await FoodItemRepository.GetAsync(filter)); }
/// <summary> /// Gets game by name /// </summary> public Task<IEnumerable<IGame>> GetRangeAsync(string name, GenericFilter filter) { return gamesRepository.GetRangeAsync(name, filter); }
/// <summary> /// Get by name /// </summary> public virtual Task<IEnumerable<IPublisher>> GetRangeAsync(string name, GenericFilter filter) { return publisherRepository.GetRangeAsync(name, filter); }
/// <summary> /// Get collection of posts /// </summary> /// <param name="gameId">Game id</param> /// <param name="filter">Filter</param> /// <returns>Collection of posts</returns> public Task<IEnumerable<Model.Common.IPost>> GetPosts(Guid gameId, GenericFilter filter) { return postRepository.GetRangeAsync(gameId, filter); }
public async Task<HttpResponseMessage> GetRangeFromPublisherId(Guid id, int pageNumber, int pageSize) { try { GenericFilter filter; if (pageNumber <= 0 && pageSize <= 0) filter = null; else filter = new GenericFilter(pageNumber, pageSize); IEnumerable<IGame> result = await GamesService.GetRangeAsync(id, filter); if (result != null) return Request.CreateResponse(HttpStatusCode.OK, Mapper.Map<IEnumerable<GameModel>>(result)); else return Request.CreateResponse(HttpStatusCode.NotFound); } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); } }
/// <summary> /// Gets orders made by user /// </summary> /// <param name="userId">User id</param> /// <param name="filter">Filter options</param> /// <returns>Collection of orders</returns> public async Task<ICollection<IOrder>> GetAsync(string userId, GenericFilter filter) { return await repository.GetRangeAsync(userId, filter); }
/// <summary> /// Get collection of topics /// </summary> /// <param name="filter">Filter options</param> /// <param name="search">String to search by</param> /// <returns>Topic colletion</returns> public async Task<ICollection<ITopic>> GetRangeAsync(GenericFilter filter, string search) { return await repository.GetRangeAsync(filter, search); }
public async Task <IEnumerable <IQuestion> > GetRangeAsync(Guid fieldId, GenericFilter filter) { return(await Repository.GetRangeAsync(fieldId, filter)); }
public async Task <IEnumerable <IAnswer> > GetRangeAsync(Guid questionId, GenericFilter filter) { return(await Repository.GetRangeAsync(questionId, filter)); }
private static Expression GetExpression <T, U>(ParameterExpression param, GenericFilter filter, params string[] nestedPropety) { PropertyInfo pro = null; Type propertyType = null; Expression left = null; MemberExpression member = null; //ParameterExpression navParam = null; var nested = nestedPropety.Where(aa => aa == filter.PropertyName).FirstOrDefault(); if (nested != null) { //navParam = Expression.Parameter(typeof(U), "ex"); left = Expression.Property(param, typeof(T).GetProperty(typeof(U).Name)); left = Expression.Property(left, typeof(U).GetProperty(nested)); pro = typeof(U).GetProperty(nested); propertyType = pro.PropertyType; // member = Expression.MakeMemberAccess(navParam, pro); } else { pro = typeof(T).GetProperty(filter.PropertyName); propertyType = pro.PropertyType; member = Expression.MakeMemberAccess(param, pro); } var targetType = TypeEx.IsNullableType(pro.PropertyType) ? Nullable.GetUnderlyingType(pro.PropertyType) : pro.PropertyType; var propertyVal = Convert.ChangeType(filter.Value, targetType); ConstantExpression constant = Expression.Constant(propertyVal, targetType); if (nested != null) { switch (filter.Operation) { case Op.Equals: return(Expression.Equal(left, constant)); case Op.GreaterThan: return(Expression.GreaterThan(left, constant)); case Op.GreaterThanOrEqual: return(Expression.GreaterThanOrEqual(left, constant)); case Op.LessThan: return(Expression.LessThan(left, constant)); case Op.LessThanOrEqual: return(Expression.LessThanOrEqual(left, constant)); case Op.Contains: return(Expression.Call(left, containsMethod, constant)); case Op.StartsWith: return(Expression.Call(left, startsWithMethod, constant)); case Op.EndsWith: return(Expression.Call(left, endsWithMethod, constant)); case Op.NotEqual: return(Expression.NotEqual(left, constant)); } } else { switch (filter.Operation) { case Op.Equals: return(Expression.Equal(member, constant)); case Op.GreaterThan: return(Expression.GreaterThan(member, constant)); case Op.GreaterThanOrEqual: return(Expression.GreaterThanOrEqual(member, constant)); case Op.LessThan: return(Expression.LessThan(member, constant)); case Op.LessThanOrEqual: return(Expression.LessThanOrEqual(member, constant)); case Op.Contains: return(Expression.Call(member, containsMethod, constant)); case Op.StartsWith: return(Expression.Call(member, startsWithMethod, constant)); case Op.EndsWith: return(Expression.Call(member, endsWithMethod, constant)); case Op.NotEqual: return(Expression.NotEqual(member, constant)); } } return(null); }
public IActionResult GetUsuarios([FromQuery] GenericFilter <UsuarioListaDto> busca) { var result = _usuarioService.BuscaUsuario(busca); return(Ok(result.Items)); }
public void GenerateFailsWhenMissingConfig(AP005SendRoutingPropertyGenerator generator, IFileRepository fileRepository, IScenarioRouteWalker routeWalker, ILogger logger, AzureIntegrationServicesModel model, Application application, MigrationContext context, Exception e) { var generatedFileName = string.Empty; JObject generatedJson = null; var resourcemapkey = "resourcemapkey"; var scenarioName = "scenarioName"; var activatingIntermediaryName = "activatingIntermediaryName"; var routingProperties = new List <(string PropertyName, string PropertyValue)> { ("propertyOneName", "propertyOneValue"), ("propertyTwoName", "propertyTwoValue") }; "Given an generator" .x(() => generator.Should().BeNull()); "And a file repository" .x(() => { _mockFileRepository.Setup(f => f.WriteJsonFile( It.IsAny <string>(), It.IsAny <JObject>() )) .Callback <string, JObject>( (p1, p2) => { generatedFileName = p1; generatedJson = p2; }); fileRepository = _mockFileRepository.Object; }); "And an application" .x(() => { var activatingIntermediary = new MessageSubscriber { Activator = true, ResourceMapKey = resourcemapkey, Name = activatingIntermediaryName }; var routingProperties1 = new Dictionary <string, object>(); var intermediaryRoutingProperties = routingProperties[0]; routingProperties1[intermediaryRoutingProperties.PropertyName] = intermediaryRoutingProperties.PropertyValue; activatingIntermediary.Properties[ModelConstants.ScenarioName] = scenarioName; activatingIntermediary.Properties[ModelConstants.RoutingProperties] = routingProperties1; activatingIntermediary.Resources.Add( new TargetResourceTemplate { ResourceType = "WrongResourceType", OutputPath = "outputpath" }); var secondIntermediary = new GenericFilter { Name = "SecondIntermediary" }; var endpoint = new AdapterEndpoint { Name = "Endpoint" }; var routingProperties2 = new Dictionary <string, object>(); var endpointRoutingProperties = routingProperties[1]; routingProperties2[endpointRoutingProperties.PropertyName] = endpointRoutingProperties.PropertyValue; endpoint.Properties[ModelConstants.RoutingProperties] = routingProperties2; application = new Application(); application.Intermediaries.Add(activatingIntermediary); application.Intermediaries.Add(secondIntermediary); application.Endpoints.Add(endpoint); }); "And a model" .x(() => { model = new AzureIntegrationServicesModel(); model.MigrationTarget.MessageBus = new MessageBus(); model.MigrationTarget.MessageBus.Applications.Add(application); }); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "And a route walker" .x(() => { var route = new List <(MessagingObject RoutingObject, Channel InputChannel)>(); foreach (var intermediary in application.Intermediaries) { route.Add((intermediary, null)); } foreach (var endpoint in application.Endpoints) { route.Add((endpoint, null)); } var mockRouteWalker = new Mock <IScenarioRouteWalker>(); mockRouteWalker.Setup(w => w.WalkSendRoute( It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Intermediary>(), It.IsAny <IEnumerable <Intermediary> >(), It.IsAny <IEnumerable <Channel> >(), It.IsAny <IEnumerable <Endpoint> >() )).Returns(route); routeWalker = mockRouteWalker.Object; }); "And a generator" .x(() => generator = new AP005SendRoutingPropertyGenerator(fileRepository, routeWalker, model, context, logger)); "When converting" .x(async() => e = await Record.ExceptionAsync(async() => await generator.ConvertAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false)); "Then the code should not throw an exception" .x(() => e.Should().BeNull()); "And there should be one context error" .x(() => { context.Errors.Should().NotBeNullOrEmpty(); context.Errors.Should().HaveCount(1); context.Errors[0].Message.Should().Contain(ModelConstants.ResourceTypeRoutingProperties); context.Errors[0].Message.Should().Contain(activatingIntermediaryName); }); }
/// <summary> /// Returns collection of publishers /// </summary> public virtual Task<IEnumerable<IPublisher>> GetRangeAsync(GenericFilter filter = null) { return publisherRepository.GetRangeAsync(filter); }
/// <summary> /// Get games from publisher, where games are not in cart /// </summary> /// <param name="publisherId">FK</param> /// <returns>Collection of games that belong to publisher</returns> public async Task<IEnumerable<IGame>> GetRangeAsync(Guid publisherId, GenericFilter filter = null) { try { if (filter != null) { return Mapper.Map<IEnumerable<IGame>>(await repository .Where<GameEntity>().Where(g => g.PublisherId == publisherId && g.IsInCart == false) .OrderBy(g => g.Name) .Skip((filter.PageNumber * filter.PageSize) - filter.PageSize) .Take(filter.PageSize).ToListAsync()); } else { return Mapper.Map<IEnumerable<IGame>>(await repository .GetRangeAsync<GameEntity>(g => g.PublisherId == publisherId && g.IsInCart == false)); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Get games that belong to publisher /// </summary> /// <param name="publisherId">FK id</param> /// <returns>Collection of games</returns> public Task<IEnumerable<Model.Common.IGame>> GetRangeAsync(Guid publisherId, GenericFilter filter = null) { return gamesRepository.GetRangeAsync(publisherId, filter); }
public async Task <IEnumerable <IField> > GetRangeAsync(GenericFilter filter) { return(await Repository.GetRangeAsync(filter)); }
public async Task <IActionResult> ListGetAllSapPoderContacto(GenericFilter filters) { List <SapPoderContacto> response = await _mtrContactosService.GetAllSapPoderContacto(); return(Ok(response)); }
private static BinaryExpression GetExpression <T>(ParameterExpression param, GenericFilter filter1, GenericFilter filter2) { Expression bin1 = GetExpression <T>(param, filter1); Expression bin2 = GetExpression <T>(param, filter2); return(Expression.AndAlso(bin1, bin2)); }
/// <summary> /// Get images that belong to game /// </summary> /// <param name="gameId">GameId</param> /// <param name="filter">Filter</param> /// <returns>Collection of games</returns> public async Task<IEnumerable<IGameImage>> GetRangeAsync(Guid gameId, GenericFilter filter) { return await repository.GetRangeAsync(gameId, filter); }
/// <summary> /// Get images that belong to recipe /// </summary> /// <param name="recipeId">RecipeId</param> /// <param name="filter">Filter</param> /// <returns>Collection of games</returns> public async Task <List <IRecipePicture> > GetRangeAsync(string recipeId, GenericFilter filter) { return(await repository.GetRangeAsync(recipeId, filter)); }