private List <FilterDefinition <Flight> > CreateClauses(SearchCriteriaModel criteriaModel, FilterDefinitionBuilder <Flight> filterBuilder)
        {
            var clauses = new List <FilterDefinition <Flight> >();

            if (criteriaModel.FromDate != null)
            {
                var fromDate = DateTime.SpecifyKind(DateTime.Parse(criteriaModel.FromDate), DateTimeKind.Utc);
                var clause   = filterBuilder.Gte(f => f.FlightDate, fromDate);
                clauses.Add(clause);
            }
            if (criteriaModel.ToDate != null)
            {
                var toDate = DateTime.SpecifyKind(DateTime.Parse(criteriaModel.ToDate), DateTimeKind.Utc);
                var clause = filterBuilder.Lte(f => f.FlightDate, toDate);
                clauses.Add(clause);
            }
            if (criteriaModel.AirlineId != null)
            {
                var clause = filterBuilder.Eq(f => f.AirlineId, criteriaModel.AirlineId.Value);
                clauses.Add(clause);
            }
            if (criteriaModel.OriginId != null)
            {
                var clause = filterBuilder.Eq(f => f.OriginAirportId, criteriaModel.OriginId.Value);
                clauses.Add(clause);
            }
            if (criteriaModel.DestinationId != null)
            {
                var clause = filterBuilder.Eq(f => f.DestinationAirportId, criteriaModel.DestinationId.Value);
                clauses.Add(clause);
            }
            return(clauses);
        }
Example #2
0
        public ActionResult Ajax_QueryFood()
        {
            var pageIndex = int.Parse(Request["page"]);

            var pageSize = int.Parse(Request["size"]);

            var result = new AjaxResult {
                Success = true
            };

            SearchCriteriaModel filter = new SearchCriteriaModel();

            filter.Category1ID = int.Parse(ConfigurationManager.AppSettings["ECCategoryID"]);

            NameValueCollection pageInfo = new NameValueCollection();

            pageInfo.Add("pageIndex", pageIndex.ToString());
            pageInfo.Add("pageSize", pageSize.ToString());
            ProductSearchResultVM data = SearchManager.Search(filter, pageInfo);

            data.ProductList.CurrentPageData.ForEach(p => {
                p.ProductDefaultImage = ProductFacade.BuildProductImage(ImageSize.P240, p.ProductDefaultImage);
            });
            result.Data = new {
                List      = data.ProductList.CurrentPageData,
                PageCount = data.ProductList.TotalPages
            };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        private async Task <SearchResultViewModel> CreateSearchResultViewModelAsync(SearchCriteriaModel criteriaModel)
        {
            var client     = __client.Value;
            var database   = client.GetDatabase("flights");
            var collection = database.GetCollection <Flight>("flights");

            var aggregateOfFlight = collection.Aggregate();

            var filter = CreateFilter(criteriaModel);

            if (filter != null)
            {
                aggregateOfFlight = aggregateOfFlight.Match(filter);
            }

            var aggregateOfSearchResultViewModel = aggregateOfFlight.Group(
                f => 1,
                g => new SearchResultViewModel
            {
                TotalNumberOfFlights        = g.Count(),
                TotalNumberOfDelayedFlights = g.Sum(f => f.ArrivalDelay > 0.0 ? 1 : 0),
                AverageDelayInMinutes       = (double)g.Average(f => f.ArrivalDelay > 0.0 ? (double?)f.ArrivalDelay : null)
            });

            return(await aggregateOfSearchResultViewModel.SingleAsync());
        }
        public ActionResult Search(SearchCriteriaModel searchModel)
        {
            var result =
                _CreepingAndRollSpeedDurationDomain.Search(ConvertHelper.ConvertToDateTimeFull(searchModel.StartDate),
                                                           ConvertHelper.ConvertToDateTimeFull(searchModel.EndDate),
                                                           (Constants.RollMachine)Enum.Parse(typeof(Constants.RollMachine), searchModel.Location),
                                                           searchModel.Mode);

            return(Json(result.Data, JsonRequestBehavior.AllowGet));
        }
Example #5
0
        public ActionResult AjaxBrandProducts(int ID)
        {
            SearchCriteriaModel criteria = new SearchCriteriaModel()
            {
                BrandID  = ID,
                PageSize = 6
            };
            ProductSearchResultVM pageVM = SearchManager.Search(criteria, HttpContext.Request.QueryString);

            return(PartialView("_BrandProductList", pageVM));
        }
Example #6
0
        private static T CreateSearchCriteria <T>(SearchCriteriaModel model) where T : SearchCriteria, new()
        {
            T criteria = new T();

            criteria.PageNumber    = model.CurrentPage;
            criteria.PageSize      = BaseController.PageSize;
            criteria.Sort          = model.GetSortColumn();
            criteria.SortDirection = model.GetSortDirection();

            return(criteria);
        }
        public ActionResult GetDataWindow2(SearchCriteriaModel model, GridSettings gridSettings)
        {
            var inputDate = !string.IsNullOrEmpty(model.StartDate) ? ConvertHelper.ConvertToDateTimeFull(model.StartDate) : DateTime.Now;
            var dataDate  = !string.IsNullOrEmpty(model.EndDate) ? ConvertHelper.ConvertToDateTimeFull(model.EndDate) : DateTime.Now;
            var result    = _cleanlinessDataInputDomain.SearchDataWindow1(inputDate, dataDate, model.Location, gridSettings);

            if (!result.IsSuccess)
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }
            return(Json(result.Data, JsonRequestBehavior.AllowGet));
        }
Example #8
0
        public JsonResult Search(SearchCriteriaModel criteria)
        {
            SearchManager     manager = new SearchManager();
            SearchResultModel list    = manager.Search(criteria);
            var result = new AjaxResult
            {
                Success = true,
                Data    = list
            };

            return(Json(result));
        }
Example #9
0
        public ActionResult LoadData()
        {
            var draw          = Request.Form.GetValues("draw").FirstOrDefault();
            var start         = Request.Form.GetValues("start").FirstOrDefault();
            var length        = Request.Form.GetValues("length").FirstOrDefault();
            var search        = Request["search[value]"];
            var colIndex      = Convert.ToInt32(Request.Form.GetValues("order[0][column]").First());
            var sortColumnDir = Request.Form.GetValues("order[0][dir]").FirstOrDefault();
            //  var sortColumn = Request.Form.GetValues("columns[" + Request.Form.GetValues("order[0][column]").FirstOrDefault() + "][name]").FirstOrDefault();
            //  int colIndex = 0;

            //  if (sortColumn != null && sortColumn.Equals("OrederRef"))
            //  {
            //      colIndex = 0;
            //  }
            // else if (sortColumn != null && sortColumn.Equals("CommercialName"))
            //  {
            //      colIndex = 1;
            //  }
            //else  if (sortColumn != null && sortColumn.Equals("Quantity"))
            //  {
            //      colIndex = 2;
            //  }
            //else  if (sortColumn != null && sortColumn.Equals("Amounts"))
            //  {
            //      colIndex = 3;
            //  }
            //else  if (sortColumn != null && sortColumn.Equals("OrderDate"))
            //  {
            //      colIndex = 4;
            //  }
            // else if (sortColumn != null && sortColumn.Equals("StatusDescription"))
            //  {
            //      colIndex = 5;
            //  }



            SearchCriteriaModel aCriteriaModel = new SearchCriteriaModel
            {
                DisplayLength   = Convert.ToInt32(length),
                DisplayStart    = Convert.ToInt32(start),
                Search          = search,
                SortColomnIndex = colIndex,
                SortDirection   = sortColumnDir
            };

            var v            = _iOrderManager.GetOrder(aCriteriaModel);
            int recordsTotal = _iOrderManager.GetAll().Count();

            return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = v }, JsonRequestBehavior.AllowGet));
        }
Example #10
0
 static void Main(string[] args)
 {
     SearchProvider of = new SearchProvider();
     //OpenFact.RefreshTokenModel oRefreshToken = new OpenFact.RefreshTokenModel();
     //TokenModel oTokenModel = new TokenModel();
     SearchCriteriaModel model = new SearchCriteriaModel();
     string clientId           = "openfact-web-console";
     //oTokenModel.refreshToken = "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJGSjg2R2NGM2pUYk5MT2NvNE52WmtVQ0lVbWZZQ3FvcXRPUWVNZmJoTmxFIn0.eyJqdGkiOiIwNjQ1NTVmNi03ZWY2LTQwOWUtODliZC04NzRkMmM2NDBiYzIiLCJleHAiOjAsIm5iZiI6MCwiaWF0IjoxNTI5MzU3ODczLCJpc3MiOiJodHRwOi8va2V5Y2xvYWsta2V5Y2xvYWstc3NvLWRldmVsb3BtZW50LmFwcHMuY29uc29sZS5zaXN0Y29vcC5vcmcvYXV0aC9yZWFsbXMvYWhyZW4iLCJhdWQiOiJvcGVuZmFjdC13ZWItY29uc29sZSIsInN1YiI6IjY5YTU1MjU2LTA5YzMtNGI0Yy04MjNlLTUzMGMzYjJiZmE5OSIsInR5cCI6Ik9mZmxpbmUiLCJhenAiOiJvcGVuZmFjdC13ZWItY29uc29sZSIsIm5vbmNlIjoiNjYzZWZlZjktMjYxYy00NTVkLWE0MGUtYmI5NDkxZmRlMjQ1IiwiYXV0aF90aW1lIjowLCJzZXNzaW9uX3N0YXRlIjoiNzhmMzMwNzYtM2EwOS00OTk5LTlmN2ItYTc5YTJiYzcxYWM5IiwiY2xpZW50X3Nlc3Npb24iOiI1OTcyMWNlMS05OTVkLTRjNDItYWI4Zi00ZTA3N2ZhZGZhZmYiLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsib3JnYW5pemF0aW9uLW1hbmFnZXIiLCJvZmZsaW5lX2FjY2VzcyIsImFkbWluIiwib3JnYW5pemF0aW9uLXVzZXIiLCJ1bWFfYXV0aG9yaXphdGlvbiJdfSwicmVzb3VyY2VfYWNjZXNzIjp7Im9wZW5mYWN0Ijp7InJvbGVzIjpbIm1hbmFnZS1ldmVudHMiLCJtYW5hZ2Utb3JnYW5pemF0aW9uIiwidmlldy1ldmVudHMiLCJ2aWV3LWRvY3VtZW50cyIsImNyZWF0ZS1vcmdhbml6YXRpb24iLCJtYW5hZ2UtZG9jdW1lbnRzIiwidmlldy1vcmdhbml6YXRpb24iXX0sImFjY291bnQiOnsicm9sZXMiOlsibWFuYWdlLWFjY291bnQiLCJtYW5hZ2UtYWNjb3VudC1saW5rcyIsInZpZXctcHJvZmlsZSJdfX19.YlUEofqgbxjcfrQF2WsoHDVCOUJUtbs6lzRpDAlipG6GG6x6wTHdlmHohgcZCy0kCJ3pKf4QNSCJg81xjM6abboPVu0nV-LS9iXksGlG0Rlwg5SwmgOkjk3G1ff7eqO7DH7tyFeEcODQ4Qmmh1YrjjBipxcbBR3jWqZrLszWdfg";
     //oTokenModel = _serviceGeneric.GetTokenEmpresa(realm);
     //http://localhost:8080/api/companies?ruc=10467793549
     //oRefreshToken = of.RefreshToken(oTokenModel.refreshToken, "http://keycloak-keycloak-sso-development.apps.console.sistcoop.org/auth/realms/ahren", clientId);
     var representation = of.companies("", "http://localhost:8080", model);
 }
Example #11
0
        /// <summary>
        /// 三级分类商品
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public ActionResult AjaxCategory3Products(int ID)
        {
            SearchCriteriaModel criteria = new SearchCriteriaModel()
            {
                Category3ID = ID,
                PageSize    = 10
            };
            ProductSearchResultVM pageVM = SearchManager.Search(criteria, HttpContext.Request.QueryString);

            ViewBag.ID = ID;

            return(PartialView("~/Views/UserControl/_SearchProductList.cshtml", pageVM));
        }
        private FilterDefinition <Flight> CreateFilter(SearchCriteriaModel criteriaModel)
        {
            var filterBuilder = Builders <Flight> .Filter;
            var clauses       = CreateClauses(criteriaModel, filterBuilder);

            if (clauses.Count > 0)
            {
                return(filterBuilder.And(clauses));
            }
            else
            {
                return(null);
            }
        }
Example #13
0
        public SearchResultsModel GetHotels(SearchCriteriaModel searchCriteria)
        {
            string baseUrl    = _siteConfiguration.BaseUrl;
            var    uriBuilder = new UriBuilder(baseUrl);
            var    query      = CreateQueryFromCriteria(searchCriteria);

            uriBuilder.Query = query.ToString();

            dynamic resultObj = InvokeUrl(uriBuilder.Uri);

            var searchResults = JsonConvert.DeserializeObject <SearchResultsModel>(resultObj);

            return(searchResults);
        }
        private SearchCriteriaModel GetCriteriaClass(RenderModel model)
        {
            SearchCriteriaModel criteriaSpotify;

            if (_mySession.CSession["SearchCriteriaModel"] == null)
            {
                criteriaSpotify = new SearchCriteriaModel(model.Content, model.CurrentCulture);
                _mySession.CSession["SearchCriteriaModel"] = criteriaSpotify;
            }
            else
            {
                criteriaSpotify = (SearchCriteriaModel)_mySession.CSession["SearchCriteriaModel"];
            }
            return(criteriaSpotify);
        }
Example #15
0
        //
        // GET: /EnvironmentManagement/EnvironmentDataDuration/

        public ActionResult Index()
        {
            var today = DateTime.Now;
            var model = new SearchCriteriaModel()
            {
                EndDate   = today.AddDays(-1).ToString("dd/MM/yyyy"),
                StartDate = today.AddDays(-89).ToString("dd/MM/yyyy"),
            };

            ViewBag.ListLocation = _environmentBaseDomain.GetLocationItemByType("1").Select(x => new SelectListItem
            {
                Text  = x.F80_Name,
                Value = x.F80_Id.ToString()
            });
            return(View(model));
        }
        public ActionResult Search(SearchCriteriaModel model)
        {
            var result =
                _xrTemperatureManagement.Search(model.Location, model.Mode,
                                                ConvertHelper.ConvertToDateTimeFull(model.StartDate),
                                                ConvertHelper.ConvertToDateTimeFull(model.EndDate)).Data;

            if (result != null)
            {
                var resultModel = new XRTemperatureManagementModel();
                resultModel.TempModel = new ChartModel()
                {
                    LstData = result.tblTemp,
                    LstTime = result.TimeTemp,
                    High    = result.HighTemp,
                    Range   = result.RangeTemp,
                    Cp      = result.CpTemp,
                    Cpk     = result.CpkTemp,
                    LCL     = result.LCLTemp,
                    Low     = result.LowTemp,
                    Mean    = result.MeanTemp,
                    Sigma   = result.SigmaTemp,
                    UCL     = result.UCLTemp
                };
                resultModel.HimIdModel = new ChartModel()
                {
                    LstData = result.tblHumid,
                    LstTime = result.TimeHumid,
                    High    = result.HighHumid,
                    Range   = result.RangeHumid,
                    Cp      = result.CpHumid,
                    Cpk     = result.CpkHumid,
                    LCL     = result.LCLHumid,
                    Low     = result.LowHumid,
                    Mean    = result.MeanHumid,
                    Sigma   = result.SigmaHumid,
                    UCL     = result.UCLHumid
                };


                return(Json(resultModel, JsonRequestBehavior.AllowGet));
            }
            return(Json(null, JsonRequestBehavior.AllowGet));
        }
Example #17
0
        /// <summary>
        /// 三级分类-详情
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public ActionResult Category3(int ID)
        {
            SearchCriteriaModel criteria = new SearchCriteriaModel()
            {
                Category3ID = ID,
                PageSize    = 10
            };
            ProductSearchResultVM pageVM = SearchManager.Search(criteria, HttpContext.Request.QueryString);

            var allCategories   = CategoryFacade.QueryCategoryInfos();
            var subCategoryInfo = allCategories.Find(f => f.CategoryType == CategoryType.SubCategory && f.CategoryID == ID);

            if (subCategoryInfo != null)
            {
                ViewBag.Title = subCategoryInfo.CategoryName;
            }
            ViewBag.ID = ID;
            return(View(pageVM));
        }
Example #18
0
        public ActionResult BrandDetail(int ID)
        {
            SearchCriteriaModel criteria = new SearchCriteriaModel()
            {
                BrandID  = ID,
                PageSize = 6
            };
            ProductSearchResultVM pageVM = SearchManager.Search(criteria, HttpContext.Request.QueryString);
            var allBrands = ProductFacade.GetAllBrands();
            var brandInfo = allBrands.Find(f => f.SysNo == ID);

            if (brandInfo != null)
            {
                ViewBag.Title = string.Format("{0}({1})", brandInfo.BrandName_Ch, brandInfo.BrandName_En);
            }
            ViewBag.ID = ID;

            return(View(pageVM));
        }
        private bool AddFavouriteTrack(SearchCriteriaModel criteriaSpotify, string addtrackid, string addtrackname)
        {
            if (addtrackid != null && addtrackname != null)
            {
                if (addtrackid != "" && addtrackname != "")
                {
                    if (!criteriaSpotify.FavouriteTracks.Exists(x => x.TrackID == addtrackid))
                    {
                        var newTrack = new FavouriteTrackItem();
                        newTrack.TrackID   = addtrackid;
                        newTrack.TrackName = addtrackname;
                        criteriaSpotify.FavouriteTracks.Add(newTrack);
                    }
                }
            }
            _mySession.CSession["SearchCriteriaModel"] = criteriaSpotify; // store in cache

            return(true);
        }
Example #20
0
        public ActionResult SearchHotel(SearchCriteriaModel searchCriteria)
        {
            if (!ModelState.IsValid)
            {
                var hotelGeneralErrorModel = new HotelGeneralModel
                {
                    SearchCriteria = searchCriteria
                };
                return(View(hotelGeneralErrorModel));
            }

            SearchResultsModel searchResultsModel = _webApiInvoker.GetHotels(searchCriteria);
            var hotelGeneralModel = new HotelGeneralModel
            {
                HotelsList     = searchResultsModel.Offers.Hotel,
                SearchCriteria = searchCriteria
            };

            return(View(hotelGeneralModel));
        }
        public async Task <ActionResult> Index(RenderModel model)
        {
            var newRecSearch = new RecommendationsModel(model.Content, model.CurrentCulture);
            SearchCriteriaModel criteriaSpotify = GetCriteriaClass(model);

            newRecSearch.criteria.seed_tracks  = string.Join(",", criteriaSpotify.FavouriteTracks.Select(x => x.TrackID).ToList());
            newRecSearch.criteria.seed_artists = "";
            newRecSearch.criteria.market       = "SE";
            newRecSearch.criteria.limit        = 50;

            var query = Request.QueryString;

            if (query != null && query.Count > 0)
            {
                criteriaSpotify.target_popularity   = int.Parse(query["target_popularity"]);
                criteriaSpotify.target_danceability = Single.Parse(query["target_danceability"]);
                criteriaSpotify.target_energy       = Single.Parse(query["target_energy"]);
                criteriaSpotify.target_tempo        = int.Parse(query["target_tempo"]);
                criteriaSpotify.target_valence      = Single.Parse(query["target_valence"]);
                criteriaSpotify.seed_genres         = query["seed_genres"].ToString();
            }
            _mySession.CSession["SearchCriteriaModel"] = criteriaSpotify;

            newRecSearch.criteria.seed_genres         = criteriaSpotify.seed_genres;
            newRecSearch.criteria.target_popularity   = criteriaSpotify.target_popularity;
            newRecSearch.criteria.target_danceability = criteriaSpotify.target_danceability;
            newRecSearch.criteria.target_energy       = criteriaSpotify.target_energy;
            newRecSearch.criteria.target_tempo        = criteriaSpotify.target_tempo;
            newRecSearch.criteria.target_valence      = criteriaSpotify.target_valence;

            var recResults = await _spotService.GetRecommendationsAsync(newRecSearch);

            ViewBag.Recommendations = recResults;
            ViewBag.GenreList       = _spotService.genres;

            return(View("Recommendations", criteriaSpotify));
        }
 private static PropertyExpressionOperator GetPropertyExpressionOperator(SearchCriteriaModel criteria)
 {
     return(criteria.Contains ? PropertyExpressionOperator.Contains : PropertyExpressionOperator.EqualTo);
 }
Example #23
0
        private string CreateQueryFromCriteria(SearchCriteriaModel searchCriteria)
        {
            var query = new StringBuilder();

            query.Append("scenario=deal-finder&page=foo&uid=foo&productType=Hotel");

            if (!string.IsNullOrEmpty(searchCriteria.DestinationName))
            {
                query.AppendFormat("&destinationName={0}", searchCriteria.DestinationName);
            }

            if (!string.IsNullOrEmpty(searchCriteria.DestinationCity))
            {
                query.AppendFormat("&destinationCity={0}", searchCriteria.DestinationCity);
            }

            if (!string.IsNullOrEmpty(searchCriteria.MinTripStartDate))
            {
                query.AppendFormat("&minTripStartDate=:{0}", searchCriteria.MinTripStartDate);
            }

            if (!string.IsNullOrEmpty(searchCriteria.MaxTripStartDate))
            {
                query.AppendFormat("&maxTripStartDate=:{0}", searchCriteria.MaxTripStartDate);
            }

            if (!string.IsNullOrEmpty(searchCriteria.MinStarRating))
            {
                query.AppendFormat("&minStarRating={0}", searchCriteria.MinStarRating);
            }

            if (!string.IsNullOrEmpty(searchCriteria.MaxStarRating))
            {
                query.AppendFormat("&maxStarRating={0}", searchCriteria.MaxStarRating);
            }

            if (!string.IsNullOrEmpty(searchCriteria.MinTotalRate))
            {
                query.AppendFormat("&minTotalRate={0}", searchCriteria.MinTotalRate);
            }

            if (!string.IsNullOrEmpty(searchCriteria.MaxTotalRate))
            {
                query.AppendFormat("&maxTotalRate={0}", searchCriteria.MaxTotalRate);
            }

            if (!string.IsNullOrEmpty(searchCriteria.MinGuestRating))
            {
                query.AppendFormat("&minGuestRating={0}", searchCriteria.MinGuestRating);
            }

            if (!string.IsNullOrEmpty(searchCriteria.MaxGuestRating))
            {
                query.AppendFormat("&maxGuestRating={0}", searchCriteria.MaxGuestRating);
            }

            if (!string.IsNullOrEmpty(searchCriteria.LengthOfStay))
            {
                query.AppendFormat("&lengthOfStay={0}", searchCriteria.LengthOfStay);
            }

            return(query.ToString());
        }
Example #24
0
        public async Task <ResponseResult <GridResponse <CategoryListingBusinessModel> > > Search(SearchCriteriaModel model, GridSettings gridSettings)
        {
            var items = from p in _categoryRepository.GetAllNonDelete()
                        select new CategoryListingBusinessModel
            {
                Id   = p.Id,
                Name = p.Name
            };

            if (!string.IsNullOrEmpty(model.Keyword))
            {
                items = items.Where(r => r.Name.Contains(model.Keyword));
            }

            var totalItems = await items.CountAsync();

            OrderBy(ref items, gridSettings);
            Paging(ref items, gridSettings);

            var results = new GridResponse <CategoryListingBusinessModel>(await items.ToListAsync(), totalItems);

            return(new ResponseResult <GridResponse <CategoryListingBusinessModel> >(results, true));
        }
        public async Task <ActionResult> Search(SearchCriteriaModel criteriaModel)
        {
            var viewModel = await CreateSearchResultViewModelAsync(criteriaModel);

            return(View("SearchResultView", viewModel));
        }
Example #26
0
        public async Task <ResponseResult <GridResponse <ProductListingBusinessModel> > > Search(SearchCriteriaModel model, GridSettings gridSettings)
        {
            var items = from p in _iTemoUnitOfWork.ProductRepository.GetAll()
                        join c in _iTemoUnitOfWork.CategoryRepository.GetAllNonDelete()
                        on p.CategoryId equals c.Id into data
                        from item in data.DefaultIfEmpty()
                        select new ProductListingBusinessModel
            {
                Id          = p.Id,
                Name        = p.Name,
                Code        = p.Code,
                Description = p.Description,
                Qty         = p.Qty,
                Status      = p.Status,
                Category    = item.Name,
                IsDeleted   = p.IsDeleted,
                CreatedById = p.CreatedById
            };

            switch (model.ViewName)
            {
            case Constants.ProductViewType.InActiveProducts:
                items = items.Where(r => r.IsDeleted);
                break;

            case Constants.ProductViewType.MyProducts:
                items = items.Where(r => r.CreatedById != null);
                break;

            case Constants.ProductViewType.AllProducts:
                items = items.Where(r => !r.IsDeleted);
                break;

            default:
                items = items.Where(r => !r.IsDeleted);
                break;
            }

            if (!string.IsNullOrEmpty(model.Keyword))
            {
                items = items.Where(r => r.Name.Contains(model.Keyword) ||
                                    r.Description.Contains(model.Keyword) ||
                                    r.Code.Contains(model.Keyword) ||
                                    r.Status.Contains(model.Keyword) ||
                                    r.Category.Contains(model.Keyword));
            }

            var totalItems = await items.CountAsync();

            OrderBy(ref items, gridSettings);
            Paging(ref items, gridSettings);

            var results = new GridResponse <ProductListingBusinessModel>(await items.ToListAsync(), totalItems);

            return(new ResponseResult <GridResponse <ProductListingBusinessModel> >(results, true));
        }
Example #27
0
 public IEnumerable <ViewOrder> GetOrder(SearchCriteriaModel searchCriteria)
 {
     return(_iOrderGateway.GetOrder(searchCriteria));
 }
        public async new Task <ActionResult> Search(RenderModel model)
        {
            SpotifySearchResults searchResults;

            var query = Request.QueryString;
            var cont  = model.Content;

            SearchCriteriaModel criteriaSpotify = GetCriteriaClass(model);

            if (query.Count > 0)
            {
                criteriaSpotify.SearchText = query["searchText"];
                // Checkboxes may have entries duplicated in QueryString, but when true exists - they are Checked
                criteriaSpotify.ListAlbums   = query["ListAlbums"].ToLower().Contains("true");
                criteriaSpotify.ListArtists  = query["ListArtists"].ToLower().Contains("true");
                criteriaSpotify.ListPlaylist = query["ListPlaylist"].ToLower().Contains("true");
                criteriaSpotify.ListTrack    = query["ListTrack"].ToLower().Contains("true");
                if (query["ShowPage"] != null)
                {
                    criteriaSpotify.PageNumber = int.Parse(query["ShowPage"]);
                }

                if (query["addTrackid"] != null)
                {
                    // Just adding a new favourite, do not load more searches
                    AddFavouriteTrack(criteriaSpotify, query["addTrackid"], query["addTrackname"]);

                    // Remove any selected Favourite tracks from the display output
                    // as the User has already chosen them
                    searchResults = (SpotifySearchResults)_mySession.CSession["SearchSearchResults"];

                    searchResults.RemoveFavouriteTracks(criteriaSpotify.FavouriteTracks.Select(x => x.TrackID).ToList());

                    return(View("ChooseFavouriteSongs", criteriaSpotify));
                }
            }

            // Wrong place for a default value of SearchText, perhaps best from Umbraco instead
            if (criteriaSpotify.SearchText == null)
            {
                criteriaSpotify.SearchText = "eye of the tiger";
            }

            if (ModelState.IsValid && criteriaSpotify.TypeParamString() != "")
            {
                if (criteriaSpotify.PageNumber <= 0)
                {
                    criteriaSpotify.PageNumber = 1;
                }

                searchResults = await _spotService.GetSearchResultsAsync(criteriaSpotify.SearchText
                                                                         , criteriaSpotify.TypeParamString(), criteriaSpotify.PageSize, (criteriaSpotify.PageNumber - 1) *criteriaSpotify.PageSize);

                criteriaSpotify.IsNextPage = false;
                if (searchResults != null)
                {
                    if (searchResults.albums == null ? false : searchResults.albums.next != null)
                    {
                        criteriaSpotify.IsNextPage = true;
                    }
                    if (searchResults.artists == null ? false : searchResults.artists.next != null)
                    {
                        criteriaSpotify.IsNextPage = true;
                    }
                    if (searchResults.playlists == null ? false : searchResults.playlists.next != null)
                    {
                        criteriaSpotify.IsNextPage = true;
                    }
                    if (searchResults.tracks == null ? false : searchResults.tracks.next != null)
                    {
                        criteriaSpotify.IsNextPage = true;
                    }
                }

                // Remove any selected Favourite tracks from the display output
                // as the User has already chosen them
                searchResults.RemoveFavouriteTracks(criteriaSpotify.FavouriteTracks.Select(x => x.TrackID).ToList());

                _mySession.CSession["SearchSearchResults"] = searchResults;
                ViewBag.SearchSpotify = searchResults;
            }

            _mySession.CSession["SearchCriteriaModel"] = criteriaSpotify;
            return(View("ChooseFavouriteSongs", criteriaSpotify));
        }
        public SearchResultsModel <CompanieModel> companies(string token, string urlApiSearch, SearchCriteriaModel model)
        {
            string urlApiDocument = urlApiSearch + "/api/companies";
            SearchResultsModel <CompanieModel> result = new SearchResultsModel <CompanieModel>();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(urlApiDocument);
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
                var response = client.PostAsJsonAsync("search", model).Result;

                if (response.IsSuccessStatusCode)
                {
                    var responseString = response.Content.ReadAsStringAsync().Result;
                    result = JsonConvert.DeserializeObject <SearchResultsModel <CompanieModel> >(responseString);
                    //result.items = representations;
                    //result.totalSize = representations.Count;
                }
            }
            return(result);
        }
Example #30
0
        public ActionResult Search(SearchCriteriaModel model)
        {
            var id  = Convert.ToInt32(model.Location);
            var dt1 = DateTime.ParseExact(model.StartDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            var dt2 = DateTime.ParseExact(model.EndDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);

            if (dt2 > DateTime.Now)
            {
                return(Json(new
                {
                    Success = false,
                    ErrorCode = -2,
                    Message = "The End Date is invalid."
                }, JsonRequestBehavior.AllowGet));
            }

            if ((dt2 - dt1).Days >= 90)
            {
                return(Json(new
                {
                    Success = false,
                    ErrorCode = -2,
                    Message = "The different of dates is more than 90 days!"
                }, JsonRequestBehavior.AllowGet));
            }

            if (dt2 < dt1)
            {
                return(Json(new
                {
                    Success = false,
                    ErrorCode = -2,
                    Message = "The Start date is larger than the End date!"
                }, JsonRequestBehavior.AllowGet));
            }

            if (ModelState.IsValid)
            {
                // get and set
                //	Declare some global variables:
                //	Boolean:
                //	b_DispHumidity;
                //	b_TEMPUSL_NULL;
                //	b_HUMIDUSL_NULL
                //	Float:
                //	T_USL, T_LSL, T_UCL, T_LCL, T_Disp UP, T_Disp LO, T_Cal UP, T_Cal LO, H_USL, H_LSL, H_UCL, H_LCL, H_Disp UP, H_Disp LO, H_Cal UP, H_Cal LO
                var localtion =
                    _environmentBaseDomain.GetLocationItemByType("1")
                    .Where(x => x.F80_Id.ToString().Equals(model.Location))
                    .FirstOrDefault();

                var envMespData = _environmentBaseDomain.GetMespVal(Constants.EnvType.TYPE_RM, int.Parse(model.Location),
                                                                    model.Mode);


                if (!envMespData.Item1)
                {
                    return(Json(new
                    {
                        Success = false,
                        ErrorCode = -1,//Reset graph and all fields in the form
                        Message = envMespData.Item2
                    }, JsonRequestBehavior.AllowGet));
                }
                var b_TEMPUSL_NULL  = false;
                var b_HUMIDUSL_NULL = false;
                if (envMespData.Item3.F80_T_Usl == null)
                {
                    envMespData.Item3.F80_T_Usl = envMespData.Item3.F80_T_Ucl;
                    b_TEMPUSL_NULL = true;
                }

                if (envMespData.Item3.F80_H_Usl == null)
                {
                    envMespData.Item3.F80_H_Usl = envMespData.Item3.F80_H_Ucl;
                    b_HUMIDUSL_NULL             = true;
                }

                double t_ucl;
                double t_lcl;
                double t_usl;
                double t_lsl;
                double t_dis_up;
                double h_dis_up;
                double t_dis_lo;
                double h_dis_lo;
                double h_ucl;
                double h_lcl;
                double h_usl;
                double h_lsl;
                double t_cal_up;
                double t_cal_lo;
                double h_cal_up;
                double h_cal_lo;
                double rl_upper;
                double rl_lower;
                double rl_max;
                double rl_min;

                string temp_hi;
                string temp_lo;
                string temp_range;
                string temp_mean;
                string temp_sigma;
                string temp_ucl;
                string temp_lcl;
                string temp_cp;
                string temp_cpk;

                string humid_mean;
                string humid_sigma;
                string humid_hi;
                string humid_lo;
                string humid_range;
                string humid_ucl;
                string humid_lcl;
                string humid_cp;
                string humid_cpk;

                _environmentBaseDomain.SetValueConfigFromTe80(envMespData.Item3, out t_ucl, out t_lcl, out t_usl, out t_lsl, out t_dis_up, out h_dis_up,
                                                              out t_dis_lo, out h_dis_lo, out h_ucl, out h_lcl, out h_usl, out h_lsl, out t_cal_up, out t_cal_lo, out h_cal_up, out h_cal_lo);

                var data = new List <Graphtbl>();

                var t80Evn =
                    _environmentBaseDomain.GetLocationItemByType("1")
                    .Where(x => x.F80_Id == id).FirstOrDefault();
                var b_DispHumidity = false;
                if (t80Evn.F80_Humidity == "0")
                {
                    b_DispHumidity = false;
                }
                else
                {
                    b_DispHumidity = true;
                }

                for (DateTime datetime = dt1; datetime <= dt2; datetime = datetime.AddDays(1))
                {
                    var calcData1 = _environmentBaseDomain.CalcData(Constants.EnvType.TYPE_RM, id, null, datetime,
                                                                    Constants.TypeOfTable.CALC_TE81_TEMP90, 1,
                                                                    model.Mode, t_ucl, t_lcl, t_usl, t_lsl, t_dis_up, h_dis_up, t_dis_lo, h_dis_lo, h_ucl, h_lcl, h_usl,
                                                                    h_lsl, t_cal_up, t_cal_lo, h_cal_up, h_cal_lo, b_DispHumidity, data);
                    if (!calcData1)
                    {
                        return(Json(new
                        {
                            Success = false,
                            ErrorCode = 0, //Nothing to do
                        }, JsonRequestBehavior.AllowGet));
                    }
                }

                var totalRecord = 0;
                var calcData    = _environmentBaseDomain.CalcData(Constants.EnvType.TYPE_RM, id, Constants.TypeOfTable.CALC_TE81_TEMP90, dt1,
                                                                  Constants.TypeOfTable.CALC_TETMP_TEMP90, (dt2 - dt1).Days,
                                                                  model.Mode, t_ucl, t_lcl, t_usl, t_lsl, t_dis_up, h_dis_up, t_dis_lo, h_dis_lo, h_ucl, h_lcl, h_usl,
                                                                  h_lsl, t_cal_up, t_cal_lo, h_cal_up, h_cal_lo, b_DispHumidity, data);
                if (!calcData)
                {
                    return(Json(new
                    {
                        Success = false,
                        ErrorCode = 0, //Nothing to do
                    }, JsonRequestBehavior.AllowGet));
                }
                dt1 = dt1.AddHours(8);
                dt2 = dt2.AddHours(8);
                var tcalcMean = _environmentBaseDomain.CalcMean(Constants.TypeOfTable.CALC_BUFFER,
                                                                Constants.TypeOfTable.CALC_TETMP_TEMP90, id, dt1, dt2,
                                                                t_cal_up, t_cal_lo, h_cal_up, h_cal_lo, data);
                if (tcalcMean.Item1)
                {
                    _environmentBaseDomain.UpdateBuffer(Constants.EnvActionBuffer.UPDATE_DB,
                                                        Constants.TypeOfTable.CALC_TETMP_TEMP90, dt1, tcalcMean.Item2, Constants.EnvFieldNo.FLD_MEAN,
                                                        data);
                }
                else
                {
                    return(Json(new
                    {
                        Success = false,
                        ErrorCode = 0, //Nothing to do
                        Message = tcalcMean.Item2
                    }, JsonRequestBehavior.AllowGet));
                }

                var tsigma = _environmentBaseDomain.CalcSigma(Constants.TypeOfTable.CALC_BUFFER,
                                                              Constants.TypeOfTable.CALC_TETMP_TEMP90, id, dt1, dt2, t_cal_up, t_cal_lo, h_cal_up, h_cal_lo, data);

                if (model.Mode == Constants.EnvMode.ControlLine)
                {
                    rl_upper = t_ucl;
                    rl_lower = t_lcl;
                }
                else
                {
                    rl_upper = t_usl;
                    rl_lower = t_lsl;
                }
                _environmentBaseDomain.UpdateBuffer(Constants.EnvActionBuffer.UPDATE_DB, Constants.TypeOfTable.CALC_TETMP_TEMP90, dt1, rl_upper, Constants.EnvFieldNo.FLD_UPPER, data);
                _environmentBaseDomain.UpdateBuffer(Constants.EnvActionBuffer.UPDATE_DB, Constants.TypeOfTable.CALC_TETMP_TEMP90, dt1, rl_lower, Constants.EnvFieldNo.FLD_LOWER, data);

                rl_max = _environmentBaseDomain.GetMax(Constants.EnvType.TYPE_RM, Constants.TypeOfTable.CALC_BUFFER, Constants.TypeOfTable.CALC_TETMP_TEMP90, id,
                                                       dt1, dt2, t_dis_up, h_dis_up, data);
                rl_min = _environmentBaseDomain.GetMin(Constants.EnvType.TYPE_RM, Constants.TypeOfTable.CALC_BUFFER, Constants.TypeOfTable.CALC_TETMP_TEMP90, id,
                                                       dt1, dt2, t_dis_lo, h_dis_lo, data);


                temp_hi    = rl_max.ToString("N2");
                temp_lo    = rl_min.ToString("N2");
                temp_range = (rl_max - rl_min).ToString("N2");
                temp_mean  = tcalcMean.Item2.ToString("N2");
                temp_sigma = tsigma.Item2.ToString("N2");
                temp_ucl   = rl_upper.ToString("N2");
                if (localtion.F80_Name.ToUpper().Contains("WAREHOUSE"))
                {
                    temp_lcl = "";
                }
                else
                {
                    temp_lcl = rl_lower.ToString("N2");
                }
                var rl_cp  = 0.0;
                var rl_cpk = 0.0;
                _environmentBaseDomain.CalcCp(Constants.TypeOfTable.CALC_TETMP_TEMP90, tcalcMean.Item2, tsigma.Item2, rl_max - rl_min, t_usl, t_lsl,
                                              ref rl_cp, ref rl_cpk, b_TEMPUSL_NULL, b_HUMIDUSL_NULL, 0.0, 0.0);
                temp_cp  = rl_cp.ToString("F");
                temp_cpk = rl_cpk.ToString("F");

                if (b_DispHumidity)
                {
                    var hcalcMean = _environmentBaseDomain.CalcMean(Constants.TypeOfTable.CALC_BUFFER,
                                                                    Constants.TypeOfTable.CALC_TETMP_HUMID90, id, dt1, dt2,
                                                                    t_cal_up, t_cal_lo, h_cal_up, h_cal_lo, data);
                    if (hcalcMean.Item1)
                    {
                        _environmentBaseDomain.UpdateBuffer(Constants.EnvActionBuffer.UPDATE_DB,
                                                            Constants.TypeOfTable.CALC_TETMP_HUMID90, dt1, hcalcMean.Item2,
                                                            Constants.EnvFieldNo.FLD_MEAN,
                                                            data);
                    }
                    else
                    {
                        var temflds = _environmentBaseDomain.GrapData(Constants.TypeOfTable.CALC_TETMP_HUMID90, data);
                        return(Json(new
                        {
                            Success = true,
                            temp_hi = temp_hi,
                            temp_lo = temp_lo,
                            temp_range = temp_range,
                            temp_mean = temp_mean,
                            temp_sigma = temp_sigma,
                            temp_cp = temp_cp,
                            temp_cpk = temp_cpk,
                            temp_ucl = temp_ucl,
                            temp_lcl = temp_lcl,
                            tem_fld_data = JsonConvert.SerializeObject(temflds.Item1),
                            tem_fld_mean = JsonConvert.SerializeObject(temflds.Item2),
                            tem_fld_upper = JsonConvert.SerializeObject(temflds.Item3),
                            tem_fld_lower = JsonConvert.SerializeObject(temflds.Item4),
                            tem_max = h_dis_up,
                            tem_min = h_dis_lo,

                            humid_mean = string.Empty,
                            humid_sigma = string.Empty,
                            humid_hi = string.Empty,
                            humid_lo = string.Empty,
                            humid_range = string.Empty,
                            humid_ucl = string.Empty,
                            humid_lcl = string.Empty,
                            humid_cp = string.Empty,
                            humid_cpk = string.Empty,
                        }, JsonRequestBehavior.AllowGet));
                    }
                    var hsigma = _environmentBaseDomain.CalcSigma(Constants.TypeOfTable.CALC_BUFFER,
                                                                  Constants.TypeOfTable.CALC_TETMP_HUMID90, id, dt1, dt2, t_cal_up, t_cal_lo, h_cal_up, h_cal_lo,
                                                                  data);

                    if (model.Mode == Constants.EnvMode.ControlLine)
                    {
                        rl_upper = h_ucl;
                        rl_lower = h_lcl;
                    }
                    else
                    {
                        rl_upper = h_usl;
                        rl_lower = h_lsl;
                    }

                    _environmentBaseDomain.UpdateBuffer(Constants.EnvActionBuffer.UPDATE_DB,
                                                        Constants.TypeOfTable.CALC_TETMP_HUMID90, dt1, rl_upper, Constants.EnvFieldNo.FLD_UPPER,
                                                        data);
                    _environmentBaseDomain.UpdateBuffer(Constants.EnvActionBuffer.UPDATE_DB,
                                                        Constants.TypeOfTable.CALC_TETMP_HUMID90, dt1, rl_lower, Constants.EnvFieldNo.FLD_LOWER,
                                                        data);

                    // Update the edit box
                    rl_max = _environmentBaseDomain.GetMax(Constants.EnvType.TYPE_RM,
                                                           Constants.TypeOfTable.CALC_BUFFER, Constants.TypeOfTable.CALC_TETMP_HUMID90, id,
                                                           dt1, dt2, t_dis_up, h_dis_up, data);
                    rl_min = _environmentBaseDomain.GetMin(Constants.EnvType.TYPE_RM,
                                                           Constants.TypeOfTable.CALC_BUFFER, Constants.TypeOfTable.CALC_TETMP_HUMID90, id,
                                                           dt1, dt2, t_dis_lo, h_dis_lo, data);
                    humid_hi    = rl_max.ToString("N2");
                    humid_lo    = rl_min.ToString("N2");
                    humid_range = (rl_max - rl_min).ToString("N2");
                    humid_mean  = hcalcMean.Item2.ToString("N2");
                    humid_sigma = hsigma.Item2.ToString("N2");
                    humid_ucl   = rl_upper.ToString("N2");


                    if (localtion.F80_Name.ToUpper().Contains("WAREHOUSE"))
                    {
                        humid_lcl = "";
                    }
                    else
                    {
                        humid_lcl = rl_lower.ToString("N2");
                    }

                    _environmentBaseDomain.CalcCp(Constants.TypeOfTable.CALC_TETMP_HUMID90, hcalcMean.Item2, hsigma.Item2, rl_max - rl_min, t_usl, t_lsl,
                                                  ref rl_cp, ref rl_cpk, b_TEMPUSL_NULL, b_HUMIDUSL_NULL, 0.0, 0.0);
                    humid_cp  = rl_cp.ToString("N2");
                    humid_cpk = rl_cpk.ToString("N2");
                }
                else
                {
                    humid_mean  = string.Empty;
                    humid_sigma = string.Empty;
                    humid_hi    = string.Empty;
                    humid_lo    = string.Empty;
                    humid_range = string.Empty;
                    humid_lcl   = string.Empty;
                    humid_cp    = string.Empty;
                    humid_cpk   = string.Empty;
                    humid_ucl   = string.Empty;
                }
                var temflds1 = _environmentBaseDomain.GrapData(Constants.TypeOfTable.CALC_TETMP_HUMID90, data);
                var hflds    = _environmentBaseDomain.GrapData(Constants.TypeOfTable.CALC_TETMP_HUMID90, data);
                return(Json(new
                {
                    Success = true,
                    temp_hi = temp_hi,
                    temp_lo = temp_lo,
                    temp_range = temp_range,
                    temp_mean = temp_mean,
                    temp_sigma = temp_sigma,
                    temp_ucl = temp_ucl,
                    temp_lcl = temp_lcl,
                    temp_cp = temp_cp,
                    temp_cpk = temp_cpk,

                    tem_fld_data = JsonConvert.SerializeObject(temflds1.Item1),
                    tem_fld_mean = JsonConvert.SerializeObject(temflds1.Item2),
                    tem_fld_upper = JsonConvert.SerializeObject(temflds1.Item3),
                    tem_fld_lower = JsonConvert.SerializeObject(temflds1.Item4),
                    tem_yAxis = JsonConvert.SerializeObject(temflds1.Item5),
                    tem_max = t_dis_up,
                    tem_min = t_dis_lo,

                    humid_mean = humid_mean,
                    humid_sigma = humid_sigma,
                    humid_hi = humid_hi,
                    humid_lo = humid_lo,
                    humid_range = humid_range,
                    humid_lcl = humid_lcl,
                    humid_ucl = humid_ucl,
                    humid_cp = humid_cp,
                    humid_cpk = humid_cpk,
                    h_fld_data = JsonConvert.SerializeObject(hflds.Item1),
                    h_fld_mean = JsonConvert.SerializeObject(hflds.Item2),
                    h_fld_upper = JsonConvert.SerializeObject(hflds.Item3),
                    h_fld_lower = JsonConvert.SerializeObject(hflds.Item4),
                    h_yAxis = JsonConvert.SerializeObject(hflds.Item5),
                    h_max = h_dis_up,
                    h_min = h_dis_lo
                }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new
            {
                Success = false,
            }, JsonRequestBehavior.AllowGet));
        }