Esempio n. 1
0
        public async Task <IActionResult> Get([FromQuery] SearchCriteriaDTO criteria)
        {
            try
            {
                var collection = await _repository.GetCollectionAsync(_mappingService.MapSearchCriteria(criteria));

                if (collection == null)
                {
                    return(NotFound("No Collection data found for specified criteria."));
                }

                // TODO - return urls in pagination ...
                // page=1 - last & next
                // page=end - first & prev
                // all other pages - first, last, prev, next

                DiscogsDTO result = _mappingService.MapCollection(collection);

                return(Ok(result));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Exception occured while getting Collection: {ex}");
            }
            return(BadRequest());
        }
Esempio n. 2
0
        public IActionResult Remove(SearchCriteriaDTO searchCriteria, int phonebookId, int entryId)
        {
            _logger.LogInformation($"[Phonebook Controller] Received search request, phonebookId:{phonebookId}");
            var PhoneEntries = _phoneService.RemoveContact(searchCriteria.EntryName, searchCriteria.EntryNumber, phonebookId, entryId);

            return(Ok(PhoneEntries));
        }
Esempio n. 3
0
        public IActionResult GetBoughtItems(SearchCriteriaDTO searchDTO, BoughtItemsOrderBy orderBy = BoughtItemsOrderBy.Name)
        {
            var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            searchDTO.UserId = userId;
            var result = _itemService.GetBoughtItems(orderBy, searchDTO);

            return(Json(result));
        }
        public List <ResultsDTO> getResults(LoginDTO credentials, SearchCriteriaDTO criteria)
        {
            List <Item> items;

            using (SearchDAL db = new SearchDAL(credentials.username, credentials.password))
            {
                items = db.getItems(criteria);
            }

            return(resultsDTOConversion(items));
        }
Esempio n. 5
0
        public List <RestaurantSearchDTO> GetRestaurantsByAnyCriteria(SearchCriteriaDTO criteria, string searchText)
        {
            List <RestaurantSearchDTO> RestaurantSearchDTOList = new List <RestaurantSearchDTO>();

            try
            {
                RestaurantSearchDTOList = this._rawSQLDbContext.GetRestaurantsByAnyCriteria(criteria, searchText);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(RestaurantSearchDTOList);
        }
Esempio n. 6
0
        public List <RestaurantSearchDTO> GetNearRestaurants(SearchCriteriaDTO criteria)
        {
            List <RestaurantSearchDTO> RestaurantSearchDTOList = new List <RestaurantSearchDTO>();

            try
            {
                RestaurantSearchDTOList = this._rawSQLDbContext.GetNearRestaurants(criteria);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(RestaurantSearchDTOList);
        }
Esempio n. 7
0
        public List <MenuItemSearchDTO> GetAllNearByMenuItems(SearchCriteriaDTO criteria)
        {
            List <MenuItemSearchDTO> MenuItemSearchDTOList = new List <MenuItemSearchDTO>();

            try
            {
                MenuItemSearchDTOList = this._rawSQLDbContext.GetAllNearByMenuItems(criteria);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(MenuItemSearchDTOList);
        }
Esempio n. 8
0
        public PagedWaitingItemsDTO GetWaitingItems(WaitingItemsOrderBy orderBy, SearchCriteriaDTO searchDTO)
        {
            var         c             = searchDTO;
            var         orderSpec     = new OrderWaitingItemSpecyfication(orderBy);
            var         predicateSpec = new ItemSpecyfication(Status.Waiting, searchDTO.UserId, searchDTO.Phrase);
            var         items         = _unitOfWork.ItemRepo.GetSortedItems(predicateSpec, orderSpec);
            List <Item> list          = items.Skip((c.PageIndex - 1) * c.AmountOfPages).Take(c.AmountOfPages).ToList();
            var         result        = new PagedWaitingItemsDTO()
            {
                TotalAmount = items.Count(),
                Items       = _mapper.Map <List <Item>, List <WaitingItemDTO> >(list)
            };

            return(result);
        }
Esempio n. 9
0
        public List <RestaurantDTO> SearchRestaurants(SearchCriteriaDTO searchCriteria)
        {
            List <RestaurantDTO> Restaurants = default(List <RestaurantDTO>);

            if (searchCriteria != null)
            {
                using (IEateryDbContext context = _unitOfWork.GetEateryDbContext())
                {
                    List <Restaurant> RestaurantList = this._RestaurantRepository.GetAllQuery(context).ToList();
                    if (RestaurantList != null && RestaurantList.Any())
                    {
                        Restaurants = ObjectTypeConverter.ConvertList <Restaurant, RestaurantDTO>(RestaurantList).ToList();
                    }
                }
            }
            return(Restaurants);
        }
Esempio n. 10
0
        public async Task <IActionResult> Get([FromQuery] SearchCriteriaDTO criteria)
        {
            try
            {
                var wantlist = await _repository.GetWantlistAsync(_mappingService.MapSearchCriteria(criteria));

                if (wantlist == null)
                {
                    return(NotFound("No Wantlist data found for specified criteria."));
                }

                DiscogsDTO result = _mappingService.MapWantlist(wantlist);

                return(Ok(result));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Exception occured while getting Wantlist: {ex}");
            }
            return(BadRequest());
        }
Esempio n. 11
0
        public List <Item> getItems(SearchCriteriaDTO criteria)
        {
            String queryString;

            if (criteria.sortZ == true)
            {
                if (criteria.categoryID == 0)
                {
                    queryString = @"SELECT ItemName, ItemPrice, Description FROM Item
                                WHERE fk_personID = @personKey AND ItemPrice < @maxPrice
                                ORDER BY ItemName DESC";
                }
                else
                {
                    queryString = @"SELECT ItemName, ItemPrice, Description FROM Item
                                WHERE fk_CategoryID = @categoryKey AND fk_personID = @personKey AND ItemPrice < @maxPrice
                                ORDER BY ItemName DESC";
                }
            }
            else if (criteria.sortHighValue == true)
            {
                if (criteria.categoryID == 0)
                {
                    queryString = @"SELECT ItemName, ItemPrice, Description FROM Item
                                WHERE fk_personID = @personKey AND ItemPrice < @maxPrice
                                ORDER BY ItemPrice DESC";
                }
                else
                {
                    queryString = @"SELECT ItemName, ItemPrice, Description FROM Item
                                WHERE fk_CategoryID = @categoryKey AND fk_personID = @personKey AND ItemPrice < @maxPrice
                                ORDER BY ItemPrice DESC";
                }
            }
            else if (criteria.sortLowValue == true)
            {
                if (criteria.categoryID == 0)
                {
                    queryString = @"SELECT ItemName, ItemPrice, Description FROM Item
                                WHERE fk_personID = @personKey AND ItemPrice < @maxPrice
                                ORDER BY ItemPrice ASC";
                }
                else
                {
                    queryString = @"SELECT ItemName, ItemPrice, Description FROM Item
                                WHERE fk_CategoryID = @categoryKey AND fk_personID = @personKey AND ItemPrice < @maxPrice
                                ORDER BY ItemPrice ASC";
                }
            }
            else
            {
                if (criteria.categoryID == 0)
                {
                    queryString = @"SELECT ItemName, ItemPrice, Description FROM Item
                                WHERE fk_personID = @personKey AND ItemPrice < @maxPrice
                                ORDER BY ItemName ASC";
                }
                else
                {
                    queryString = @"SELECT ItemName, ItemPrice, Description FROM Item
                                WHERE fk_CategoryID = @categoryKey AND fk_personID = @personKey AND ItemPrice < @maxPrice
                                ORDER BY ItemName ASC";
                }
            }

            SqlCommand userQuery = new SqlCommand(queryString, conn);

            userQuery.Parameters.Add(new SqlParameter("@categoryKey", SqlDbType.Int));
            userQuery.Parameters.Add(new SqlParameter("@personKey", SqlDbType.Int));
            userQuery.Parameters.Add(new SqlParameter("@maxPrice", SqlDbType.Decimal));

            userQuery.Parameters["@categoryKey"].Value = criteria.categoryID;
            userQuery.Parameters["@personKey"].Value   = criteria.personID;
            userQuery.Parameters["@maxPrice"].Value    = criteria.maxMoney;


            return(readItems(userQuery));
        }