public IActionResult FilterData(List <int> value) { var filters = FiltersService.GetFilterList(_context); var productsByFilter = GetProductsByFilter(value, filters); return(Ok(productsByFilter)); }
public FiltersServiceTests() { _manufacturersRepositoryMock = new Mock <IManufacturersRepository>(); _osesRepositoryMock = new Mock <IOsesRepository>(); _productsRepositoryMock = new Mock <IProductsRepository>(); _filtersService = new FiltersService(_manufacturersRepositoryMock.Object, _osesRepositoryMock.Object, _productsRepositoryMock.Object); }
/// <summary> /// Initializes a new instance of the <see cref="TodoistClient" /> class. /// </summary> /// <param name="token">The token.</param> /// <param name="restClient">The rest client.</param> /// <exception cref="System.ArgumentException">Value cannot be null or empty - token</exception> public TodoistClient(string token, ITodoistRestClient restClient) { if (string.IsNullOrEmpty(token)) { throw new ArgumentException("Value cannot be null or empty.", nameof(token)); } _token = token; _restClient = restClient; Projects = new ProjectsService(this); Templates = new TemplateService(this); Items = new ItemsService(this); Labels = new LabelsService(this); Notes = new NotesService(this); Uploads = new UploadService(this); Filters = new FiltersService(this); Activity = new ActivityService(this); Notifications = new NotificationsService(this); Backups = new BackupService(this); Reminders = new RemindersService(this); Users = new UsersService(this); Sharing = new SharingService(this); Emails = new EmailService(this); Sections = new SectionService(this); }
public async Task <string> Polls([FromBody] dynamic value) { PollService _pollService = new PollService(); FiltersService _filtersService = new FiltersService(); StudentsService _studentsService = StudentsService.Instance; var resultFilter = _filtersService.GetFilter(value.ToString()); var normalizedStudentsResult = _studentsService.GetNormalizeData(); var studens = _pollService.GetPoll(resultFilter, normalizedStudentsResult); return(JsonConvert.SerializeObject(studens)); }
public FiltersTui(FiltersService service) { _service = service; Initialize("Filters TUI", new Dictionary <string, Action> { { "Filter marks by task", FilterMarksByTask }, { "Filter marks by student", FilterMarksByStudent }, { "Filter marks by period", FilterMarksByPeriod }, { "Filter marks by task and student group", FilterMarksByTaskAndStudentGroup } }); }
public void FilterByTestFailed() { Order order1 = new Order(2, "Zygmunt", new DateTime(2020, 11, 01), new DateTime(2020, 11, 14), new TimeSpan(13), "Bytom", "696778441", "kafelkowanie", 5000, "W realizacji", 3); Order order2 = new Order(3, "Dawid", new DateTime(2020, 11, 01), new DateTime(2020, 11, 10), new TimeSpan(9), "Katowice", "542355691", "gładzie", 2400, "W realizacji", 2); List <Order> listOrder1 = new List <Order>(); listOrder1.Add(order1); listOrder1.Add(order2); FiltersService service = new FiltersService(); Assert.Throws <NullReferenceException>(() => service.FilterBy("Name", "Daniel", listOrder1)); }
//1. Is Ok //2. throws exception //3. propertyName is not valid //4. Value is not convertable to propertyName //5. Operation is not valid. [Test] public void BuildExpression_WhenCalled_ShouldReturnOk() { //Arrange IEnumerable <FilterStatement <EventModel> > filterStatements = TestsFacade.FilterStatementFacade.BuildFilterStatementList <EventModel>(); FiltersService <EventModel> service = new FiltersService <EventModel>(filterStatements); //Act ResultService <Expression <Func <EventModel, bool> > > result = service.BuildExpression(); //Assert Assert.IsNotNull(result); Assert.IsInstanceOf <ResultService <Expression <Func <EventModel, bool> > > >(result); Assert.IsTrue(result.Success); }
public void FilterByTest() { Order order1 = new Order(1, "Ania", new DateTime(2020, 11, 23), new DateTime(2020, 11, 30), new TimeSpan(7), "Katowice", "542355691", "malowanie", 900, "W realizacji", 2); Order order2 = new Order(2, "Zygmunt", new DateTime(2020, 11, 01), new DateTime(2020, 11, 14), new TimeSpan(13), "Bytom", "696778441", "kafelkowanie", 5000, "W realizacji", 3); Order order3 = new Order(3, "Dawid", new DateTime(2020, 11, 01), new DateTime(2020, 11, 10), new TimeSpan(9), "Katowice", "542355691", "gładzie", 2400, "W realizacji", 2); List <Order> listOrder = new List <Order>(); listOrder.Add(order1); listOrder.Add(order2); listOrder.Add(order3); FiltersService service = new FiltersService(); var result = service.FilterBy("Address", "Katowice", listOrder); result.Should().Contain(order1); result.Should().Contain(order3); result.Should().HaveCount(2); }
static void Main(string[] args) { MenuOptionsService menuOptionsList = new MenuOptionsService(); OrdersService ordersService = new OrdersService(); FiltersService filtersService = new FiltersService(); OrdersManager ordersManager = new OrdersManager(ordersService); FiltersManager filtersManager = new FiltersManager(ordersService); ordersService.LoadFromFile(); Console.WriteLine("Witaj w aplikacji do zarządzania zleceniami."); while (true) { Console.WriteLine("Wybierz co chcesz zrobić:"); menuOptionsList.ShowItems(); var operation = Console.ReadKey(); switch (operation.KeyChar) { case '1': var key = ordersManager.CreateNewOrder(); break; case '2': var key1 = ordersManager.CancelOrder(); break; case '3': var key2 = ordersManager.SearchOrder(); break; case '4': var key3 = filtersService.ShowItems(); var choosenFilter = Console.ReadKey(); filtersManager.ChooseFilter(choosenFilter); break; default: Console.WriteLine("Wybrana operacja nie istnieje."); break; } } }
public async Task <ObservableCollection <IFiltersItemVM> > LoadFiltersFor(string categoryId, List <ApplyedFilter> applyedFilters) { ObservableCollection <IFiltersItemVM> dataSource = null; try { IEnumerable <Filter> filters = null; if (categoryId.IsNullOrEmtpy()) { filters = await FiltersService.LoadFilters(categoryId); } else if (!CachedObjects.ContainsKey(categoryId)) { filters = await FiltersService.LoadFilters(categoryId); if (!filters.IsNullOrEmpty()) { CachedObjects.Add(categoryId, filters); } } else if (CachedObjects.ContainsKey(categoryId)) { filters = CachedObjects[categoryId].Cast <Filter>(); } dataSource = new ObservableCollection <IFiltersItemVM>(filters .Select(filter => CreateItemForFilter(filter, applyedFilters)) .Where(x => x != null) ); } catch (ConnectionException ex) { OnConnectionException(ex); } catch (Exception ex) { OnException(ex); } return(dataSource); }
[Test] public void BuildExpression_WhenPropertyNull_ShouldReturnFail() { //Arrange FilterStatement <EventModel> filterStatement = TestsFacade.FilterStatementFacade.BuildFilterStatement <EventModel>(); filterStatement.PropertyName = null; IEnumerable <FilterStatement <EventModel> > filterStatements = new List <FilterStatement <EventModel> >() { filterStatement }; FiltersService <EventModel> service = new FiltersService <EventModel>(filterStatements); //Act ResultService <Expression <Func <EventModel, bool> > > result = service.BuildExpression(); //Assert Assert.IsNotNull(result); Assert.IsFalse(result.Success); Assert.IsNull(result.Value); Assert.IsTrue(result.ErrorCode == ErrorCode.EntityNotValid); }
public MainTui( TaskService taskService, StudentService studentService, MarkService markService, ReportsService reportsService, FiltersService filtersService) { var taskTui = new TaskTui(taskService); var studentTui = new StudentTui(studentService); var markTui = new MarkTui(markService); var reportsTui = new ReportsTui(reportsService); var filtersTui = new FiltersTui(filtersService); Initialize("Main TUI", new Dictionary <string, Action> { { "Tasks", taskTui.Run }, { "Students", studentTui.Run }, { "Marks", markTui.Run }, { "Reports", reportsTui.Run }, { "Filters", filtersTui.Run } }); }
public MockFilterController(ILoggerFactory loggerFactory, IFiltersService filtersService) : base(loggerFactory) { this.filtersService = (FiltersService)filtersService; }
public FiltersController() { _FiltersService = new FiltersService(); }
public When_PollService_IsCalled() { _filtersService = new FiltersService(); _studentsService = StudentsService.Instance; _pollService = new PollService(); }
public IActionResult GetFilters() { var model = FiltersService.GetFilterList(_context); return(Ok(model)); }
public When_FiltersService_IsCalled() { _filtersService = new FiltersService(); }
public FiltersManager(OrdersService ordersService) { _filtersService = new FiltersService(); _ordersService = ordersService; _ordersList = _ordersService.GetAllItems(); }