Exemplo n.º 1
0
        public FilteredList <Owner> ReadAllOwnersSearch(FilterSearch filter)
        {
            var filteredList = new FilteredList <Owner>();

            filteredList.TotalCount = _ctx.Owners.Count();
            filteredList.FilterUsed = filter;

            IEnumerable <Owner> filtering = _ctx.Owners;

            if (!string.IsNullOrEmpty(filter.SearchText))
            {
                switch (filter.SearchField)
                {
                case "FirstName":
                    filtering = filtering.Where(o => o.FirstName.ToLower().Contains(filter.SearchText.ToLower()));
                    break;

                case "LastName":
                    filtering = filtering.Where(o => o.LastName.ToLower().Contains(filter.SearchText.ToLower()));
                    break;
                }
            }

            if (!string.IsNullOrEmpty(filter.OrderDirection) && !string.IsNullOrEmpty(filter.OrderProperty))
            {
                var prop = typeof(Owner).GetProperty(filter.OrderProperty);
                filtering = "ASC".Equals(filter.OrderDirection) ?
                            filtering.OrderBy(o => prop.GetValue(o, null)) :
                            filtering.OrderByDescending(o => prop.GetValue(o, null));
            }

            filteredList.List       = filtering.ToList();
            filteredList.TotalFound = filtering.Count();
            return(filteredList);
        }
Exemplo n.º 2
0
        private void InitializeFilters()
        {
            _parameter          = System.Linq.Expressions.Expression.Parameter(typeof(ServiceLog), "s");
            _parameterSD        = System.Linq.Expressions.Expression.Parameter(typeof(ServiceDone), "sd");
            _parameterSU        = System.Linq.Expressions.Expression.Parameter(typeof(SpareUsed), "su");
            _filterDate         = new FilterDate(_parameter);
            _filterSearch       = new FilterSearch(_parameter);
            _filterStatus       = new FilterId(_parameter);
            _filterDept         = new FilterId(_parameter);
            _filterRepairer     = new FilterId(_parameter);
            _filterTypeModel    = new FilterId(_parameter);
            _filterModel        = new FilterId(_parameter);
            _filterSparesUsed   = new FilterIdAnd(_parameterSU);
            _filterServicesDone = new FilterIdAnd(_parameterSD);

            _filters = new List <BL.IFilter>();

            _filters.Add(_filterDate);
            _filters.Add(_filterSearch);
            _filters.Add(_filterStatus);
            _filters.Add(_filterRepairer);
            _filters.Add(_filterDept);
            _filters.Add(_filterTypeModel);
            _filters.Add(_filterModel);

            _filterDate.FilterCreated   += OnFilterChanged;
            _filterSearch.FilterCreated += OnFilterChanged;
        }
Exemplo n.º 3
0
        public AddServiceLogVM()
        {
            _search       = String.Empty;
            _parameter    = System.Linq.Expressions.Expression.Parameter(typeof(Device), "d");
            _filterSearch = new FilterSearch(_parameter);
            _filters      = new List <IFilter>();
            _filters.Add(_filterSearch);
            _filterSearch.FilterCreated += OnFilterChanged;
            _date = DateTime.Now;

            Devices          = new ObservableCollection <Device>();
            ParametersValues = new ObservableCollection <ParameterValue>();
            Services         = new ObservableCollection <ServiceForModel>();
            Spares           = new ObservableCollection <SpareForModel>();
            Users            = new ObservableCollection <Repairer>();

            _selectedServices = new ObservableCollection <ServiceForModel>();
            _selectedSpares   = new ObservableCollection <SpareForModel>();

            var sdbContext = SingletonDBContext.GetInstance(new SQLiteContext());

            _dbContext = sdbContext.DBContext;
            if (_dbContext is SQLiteContext)
            {
                SQLiteContext context = _dbContext as SQLiteContext;
                context.Device.Load();
                Devices = context.Device.Local.ToBindingList();
                context.Repairer.Load();
                Users = context.Repairer.Local.ToBindingList();
            }
        }
Exemplo n.º 4
0
        public FilteredList <PetType> GetAllTypesSearch(FilterSearch filter)
        {
            var filteredList = new FilteredList <PetType>();

            filteredList.TotalCount = _petTypes.Count();
            filteredList.FilterUsed = filter;

            IEnumerable <PetType> filtering = _petTypes;

            if (!string.IsNullOrEmpty(filter.SearchText))
            {
                switch (filter.SearchField)
                {
                case "Type":
                    filtering = filtering.Where(o => o.Type.ToLower().Contains(filter.SearchText.ToLower()));
                    break;
                }
            }

            if (!string.IsNullOrEmpty(filter.OrderDirection) && !string.IsNullOrEmpty(filter.OrderProperty))
            {
                var prop = typeof(PetType).GetProperty(filter.OrderProperty);
                filtering = "ASC".Equals(filter.OrderDirection) ?
                            filtering.OrderBy(o => prop.GetValue(o, null)) :
                            filtering.OrderByDescending(o => prop.GetValue(o, null));
            }

            filteredList.List       = filtering.ToList();
            filteredList.TotalFound = filtering.Count();
            return(filteredList);
        }
Exemplo n.º 5
0
        public FilteredList <Pet> GetAllPets(FilterSearch filter)
        {
            if (!string.IsNullOrEmpty(filter.SearchText) && string.IsNullOrEmpty(filter.SearchField))
            {
                filter.SearchField = "Name";
            }

            return(_petRepo.ReadAllPets(filter));
        }
Exemplo n.º 6
0
        public FilteredList <PetType> GetAllTypes(FilterSearch filter)
        {
            if (!string.IsNullOrEmpty(filter.SearchText) && string.IsNullOrEmpty(filter.SearchField))
            {
                filter.SearchField = "Type";
            }

            return(_typeRepo.GetAllTypesSearch(filter));
        }
Exemplo n.º 7
0
        public FilteredList <Owner> GetAllOwners(FilterSearch filter)
        {
            if (!string.IsNullOrEmpty(filter.SearchText) && string.IsNullOrEmpty(filter.SearchField))
            {
                filter.SearchField = "FirstName";
            }

            return(_ownerRepo.ReadAllOwnersSearch(filter));
        }
Exemplo n.º 8
0
        private void InitializeFilters()
        {
            _parameter    = System.Linq.Expressions.Expression.Parameter(typeof(Service), "s");
            _filterSearch = new FilterSearch(_parameter);

            _filters = new List <IFilter>();

            _filters.Add(_filterSearch);

            _filterSearch.FilterCreated += OnFilterChanged;
        }
Exemplo n.º 9
0
        public async Task <ActionResult <ItemDisplayView> > IndexView(FilterSearch filterSearch)
        {
            var items = (await _bll.ItemService.AllAsync(filterSearch.Search, filterSearch.CategoriesFilter, filterSearch.BrandsFilter));

            var itemsView = new ItemDisplayView()
            {
                Items      = items.Select(i => _itemMapper.MapToItemDisplay(i)),
                Categories = _bll.CategoryService.GetAllSubCategoriesAsync().Result.Select(c => _categoryMapper.Map(c)),
                Brands     = _bll.BrandService.AllAsync().Result.Select(b => _brandMapper.Map(b))
            };

            return(Ok(itemsView));
        }
Exemplo n.º 10
0
        private void InitializeFilters()
        {
            _parameter      = System.Linq.Expressions.Expression.Parameter(typeof(TypeModel), "s");
            _parameterModel = System.Linq.Expressions.Expression.Parameter(typeof(Model), "s");
            _parameterDept  = System.Linq.Expressions.Expression.Parameter(typeof(Device), "s");
            _filterSearch   = new FilterSearch(_parameter);
            _filterDept     = new FilterId(_parameterDept);
            _filterModel    = new FilterId(_parameterModel);

            _filters = new List <IFilter>();

            _filters.Add(_filterSearch);
            //_filters.Add(_filterDept);
            //_filters.Add(_filterModel);

            _filterSearch.FilterCreated += OnFilterChanged;
        }
Exemplo n.º 11
0
        public AddServiceLogViewModel()
        {
            search       = String.Empty;
            parameter    = Expression.Parameter(typeof(ServiceLog), "d");
            filterSearch = new FilterSearch(parameter);
            filters      = new List <IFilter>();
            filters.Add(filterSearch);
            filterSearch.FilterCreated += OnFilterChanged;

            Devices          = new ObservableCollection <Device>();
            ParametersValues = new ObservableCollection <ParameterValue>();
            Services         = new ObservableCollection <Service>();
            Spares           = new ObservableCollection <Spare>();

            DbContext dbContext = new SQLiteContext();

            if (dbContext is SQLiteContext)
            {
                SQLiteContext context = dbContext as SQLiteContext;
                context.Device.Load();
                Devices = context.Device.Local.ToBindingList();
            }
        }
Exemplo n.º 12
0
 public ActionResult <FilteredList <PetType> > Get([FromQuery] FilterSearch filter)
 {
     return(_typeService.GetAllTypes(filter));
 }
Exemplo n.º 13
0
        public async Task <IEnumerable <Charge> > GetChargesByAnythingAsync(IDictionary <FilterSearch, string> query = null, int page = 1, int perPage = 20, FilterSearch filterSearch = FilterSearch.created_at, SortOrder sortOrder = SortOrder.asc)
        {
            var list = await SearchByAnythingAsync("charges", query, page, perPage, filterSearch, sortOrder);

            return(FromDynamicTo <IEnumerable <Charge> >(list?.charges));
        }
Exemplo n.º 14
0
        //Retorna todos os perfis de acesso
        public async Task <IEnumerable <Role> > GetByAnythingAsync(Role Role, IDictionary <FilterSearch, String> Query = null, Int32 Page = 1, Int32 PerPage = 20, FilterSearch filterSearch = FilterSearch.id, SortOrder sortOrder = SortOrder.asc)
        {
            var list = await SearchByAnythingAsync("roles", Query, Page, PerPage, filterSearch, sortOrder);

            return(FromDynamicTo <IEnumerable <Role> >(list?.roles));
        }
Exemplo n.º 15
0
        private void FilterSearch_Click(object sender, RoutedEventArgs e)
        {
            var s = new FilterSearch();

            s.ShowDialog();
        }
Exemplo n.º 16
0
        //Retorna todos as transações
        public async Task <IEnumerable <Product> > GetByAnythingAsync(Transaction Transaction, IDictionary <FilterSearch, String> Query = null, Int32 Page = 1, Int32 PerPage = 20, FilterSearch filterSearch = FilterSearch.id, SortOrder sortOrder = SortOrder.asc)
        {
            var list = await SearchByAnythingAsync("transactions", Query, Page, PerPage, filterSearch, sortOrder);

            return(FromDynamicTo <IEnumerable <Transaction> >(list?.transactions));
        }
Exemplo n.º 17
0
        //Retorna todos os metodos de Pagamento
        public async Task <IEnumerable <PaymentMethods> > GetByAnythingAsync(PaymentMethods PaymentMethods, IDictionary <FilterSearch, String> Query = null, Int32 Page = 1, Int32 PerPage = 20, FilterSearch filterSearch = FilterSearch.id, SortOrder sortOrder = SortOrder.asc)
        {
            var list = await SearchByAnythingAsync("payment_methods", Query, Page, PerPage, filterSearch, sortOrder);

            return(FromDynamicTo <IEnumerable <PaymentMethods> >(list?.payment_methods));
        }
Exemplo n.º 18
0
 private async Task <dynamic> SearchByAnythingAsync(string uri, IDictionary <FilterSearch, string> query = null, int page = 1, int perPage = 20, FilterSearch filterSearch = FilterSearch.id, SortOrder sortOrder = SortOrder.asc)
 => await $@"{_urlApi}/{uri}?page={page}&per_page={perPage}&sort_by={filterSearch.ToString()}&sort_order={sortOrder.ToString()}{VindiQueryString(query)}"
 .WithHeaders(new { Authorization = _authorization })
 .GetJsonAsync();
Exemplo n.º 19
0
        private async Task <dynamic> SearchByAnythingAsync(String Uri, IDictionary <FilterSearch, String> Query = null, Int32 Page = 1, Int32 PerPage = 20, FilterSearch filterSearch = FilterSearch.id, SortOrder sortOrder = SortOrder.asc)
        {
            dynamic Result = "";

            try {
                Result = await $@"{UrlApi}/{Uri}?Page={Page}&per_Page={PerPage}&sort_by={filterSearch.ToString()}&sort_order={sortOrder.ToString()}{QueryString(Query)}"
                         .WithBasicAuth(Convert.ToString(Authorization), "")
                         .GetJsonAsync();
            } catch (FlurlHttpException Except) {
                FExceptionHlp = new FlurlExceptionHlp();
                String ExceptResult = FExceptionHlp.ConvertToJson(Except);
                throw new Exception(ExceptResult);
            }
            return(Result);
        }
Exemplo n.º 20
0
        public async Task <IEnumerable <Payment_Profile> > GetPaymentProfilesByAnythingAsync(IDictionary <FilterSearch, string> query = null, int page = 1, int perPage = 20, FilterSearch filterSearch = FilterSearch.id, SortOrder sortOrder = SortOrder.asc)
        {
            var list = await SearchByAnythingAsync("payment_profiles", query, page, perPage, filterSearch, sortOrder);

            return(FromDynamicTo <IEnumerable <Payment_Profile> >(list?.payment_profiles));
        }
Exemplo n.º 21
0
        public async Task <IEnumerable <Subscription> > GetSubscriptionsByAnythingAsync(IDictionary <FilterSearch, string> query = null, int page = 1, int perPage = 20, FilterSearch filterSearch = FilterSearch.id, SortOrder sortOrder = SortOrder.asc)
        {
            var list = await SearchByAnythingAsync("subscriptions", query, page, perPage, filterSearch, sortOrder);

            return(FromDynamicTo <IEnumerable <Subscription> >(list?.subscriptions));
        }
Exemplo n.º 22
0
        public async Task <IEnumerable <Merchant_Users> > GetMerchantUsersByAnythingAsync(IDictionary <FilterSearch, string> query = null, int page = 1, int perPage = 20, FilterSearch filterSearch = FilterSearch.id, SortOrder sortOrder = SortOrder.asc)
        {
            var list = await SearchByAnythingAsync("merchant_users", query, page, perPage, filterSearch, sortOrder);

            return(FromDynamicTo <IEnumerable <Merchant_Users> >(list?.merchant_users));
        }
Exemplo n.º 23
0
 public ActionResult <FilteredList <Owner> > Get([FromQuery] FilterSearch filter)
 {
     return(_ownerService.GetAllOwners(filter));
 }
Exemplo n.º 24
0
        private async Task <dynamic> SearchByAnythingAsync(String Uri, IDictionary <FilterSearch, String> Query = null, Int32 Page = 1, Int32 PerPage = 20, FilterSearch filterSearch = FilterSearch.id, SortOrder sortOrder = SortOrder.asc)
        {
            ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => { return(true); };
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            dynamic Result = "";

            try {
                Result = await $@"{UrlApi}/{Uri}?Page={Page}&per_Page={PerPage}&sort_by={filterSearch.ToString()}&sort_order={sortOrder.ToString()}{QueryString(Query)}"
                         .WithBasicAuth(Convert.ToString(Authorization), "")
                         .GetJsonAsync();
            } catch (FlurlHttpException Except) {
                FExceptionHlp = new FlurlExceptionHlp();
                String ExceptResult = FExceptionHlp.ConvertToJson(Except);
                throw new Exception(ExceptResult);
            }
            return(Result);
        }
Exemplo n.º 25
0
        //Конструктор модели представления
        public MainViewModel()
        {
            string executable = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string path       = (System.IO.Path.GetDirectoryName(executable));

            AppDomain.CurrentDomain.SetData("DataDirectory", path);

            this.AddServiceLogCommand = new DelegateCommand(ExecuteAddServiceLog);

            parameter          = Expression.Parameter(typeof(ServiceLog), "s");
            parameterSD        = Expression.Parameter(typeof(ServiceDone), "sd");
            parameterSU        = Expression.Parameter(typeof(SpareUsed), "su");
            filterDate         = new FilterDate(parameter);
            filterSearch       = new FilterSearch(parameter);
            filterStatus       = new FilterId(parameter);
            filterDept         = new FilterId(parameter);
            filterRepairer     = new FilterId(parameter);
            filterTypeModel    = new FilterId(parameter);
            filterModel        = new FilterId(parameter);
            filterSparesUsed   = new FilterIdAnd(parameterSU);
            filterServicesDone = new FilterIdAnd(parameterSD);

            filters = new List <IFilter>();

            filters.Add(filterDate);
            filters.Add(filterSearch);
            filters.Add(filterStatus);
            filters.Add(filterRepairer);
            filters.Add(filterDept);
            filters.Add(filterTypeModel);
            filters.Add(filterModel);

            filterDate.FilterCreated   += OnFilterChanged;
            filterSearch.FilterCreated += OnFilterChanged;

            FirstDate          = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            SecondDate         = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
            Spares             = new ObservableCollection <Spare>();
            Services           = new ObservableCollection <Service>();
            Models             = new ObservableCollection <Model>();
            TypesModel         = new ObservableCollection <TypeModel>();
            Depts              = new ObservableCollection <Dept>();
            Repairers          = new ObservableCollection <Repairer>();
            Statuses           = new ObservableCollection <Status>();
            ServiceLogs        = new ObservableCollection <ServiceLog>();
            ParametersValues   = new ObservableCollection <ParameterValue>();
            ServicesDone       = new ObservableCollection <ServiceDone>();
            SparesUsed         = new ObservableCollection <SpareUsed>();
            SelectedStatuses   = new ObservableCollection <Status>();
            SelectedRepairers  = new ObservableCollection <Repairer>();
            SelectedDepts      = new ObservableCollection <Dept>();
            SelectedTypesModel = new ObservableCollection <TypeModel>();
            SelectedModels     = new ObservableCollection <Model>();
            SelectedSpares     = new ObservableCollection <Spare>();
            SelectedServices   = new ObservableCollection <Service>();

            DbContext dbContext = new SQLiteContext();

            if (dbContext is SQLiteContext)
            {
                SQLiteContext context = dbContext as SQLiteContext;
                context.Status.Load();
                Statuses = context.Status.Local.ToBindingList();
                context.Repairer.Load();
                Repairers = context.Repairer.Local.ToBindingList();
                context.Dept.Load();
                Depts = context.Dept.Local.ToBindingList();
                context.TypeModel.Load();
                TypesModel = context.TypeModel.Local.ToBindingList();
                context.Model.Load();
                Models = context.Model.Local.ToBindingList();
                context.Service.Load();
                Services = context.Service.Local.ToBindingList();
                context.Spare.Load();
                Spares = context.Spare.Local.ToBindingList();
            }
        }
Exemplo n.º 26
0
 public ActionResult <FilteredList <Pet> > Get([FromQuery] FilterSearch filter)
 {
     return(_petService.GetAllPets(filter));
 }
Exemplo n.º 27
0
        public async Task <IEnumerable <Import_Batche> > GetImportBatchesByAnythingAsync(IDictionary <FilterSearch, string> query = null, int page = 1, int perPage = 20, FilterSearch filterSearch = FilterSearch.id, SortOrder sortOrder = SortOrder.asc)
        {
            var list = await SearchByAnythingAsync("import_batches", query, page, perPage, filterSearch, sortOrder);

            return(FromDynamicTo <IEnumerable <Import_Batche> >(list?.import_batches));
        }
Exemplo n.º 28
0
 public void InicializeTest()
 {
     parameter    = Expression.Parameter(typeof(ServiceLog), "s");
     filterSearch = new FilterSearch(parameter);
 }