Exemplo n.º 1
0
        public void Test_Location_Insert()
        {
            var newLocation = new Location("A", this.coords);

            this.repository.Insert(newLocation);

            Assert.AreEqual(5, repository.Count());
        }
Exemplo n.º 2
0
        public async Task <BaseViewModel <PagingResult <LocationViewModel> > > GetAllLocations(BasePagingRequestViewModel request)
        {
            var pageSize  = request.PageSize;
            var pageIndex = request.PageIndex;
            var result    = new BaseViewModel <PagingResult <LocationViewModel> >();

            string filter = SearchHelper <Location> .GenerateStringExpression(request.Filter, Constants.DEAFAULT_DELETE_STATUS_EXPRESSION);

            Expression <Func <Location, bool> > FilterExpression = await LinqHelper <Location> .StringToExpression(filter);

            QueryArgs <Location> queryArgs = new QueryArgs <Location>
            {
                Offset = pageSize * (pageIndex - 1),
                Limit  = pageSize,
                Filter = FilterExpression,
                Sort   = request.SortBy,
            };


            var data = _repository.Get(queryArgs.Filter, queryArgs.Sort, queryArgs.Offset, queryArgs.Limit).ToList();

            //var sql = data.ToSql();

            if (data == null || data.Count == 0)
            {
                result.Description = MessageHandler.CustomMessage(MessageConstants.NO_RECORD);
                result.Code        = MessageConstants.NO_RECORD;
            }
            else
            {
                var pageSizeReturn = pageSize;
                if (data.Count < pageSize)
                {
                    pageSizeReturn = data.Count;
                }
                result.Data = new PagingResult <LocationViewModel>
                {
                    Results      = _mapper.Map <IEnumerable <LocationViewModel> >(data),
                    PageIndex    = pageIndex,
                    PageSize     = pageSizeReturn,
                    TotalRecords = _repository.Count(queryArgs.Filter)
                };
            }

            return(result);
        }
        public string ShowAllLocation()
        {
            string message = "";

            message += "Anzahl Standorte: " + _locationRepository.Count() + "\n";
            List <Location> locationList;

            locationList = _locationRepository.ReadAllLocationList();
            foreach (Location location in locationList)
            {
                message += location.ToString() + "\n";
            }
            return(message);
        }
Exemplo n.º 4
0
        public Return GetAll(QueryParameters queryParameters)
        {
            List <Location> allLocations = _locationRepository
                                           .GetAll(queryParameters)
                                           .ToList();

            int allItemCount = _locationRepository.Count();



            return(new Return
            {
                locations = allLocations,
                count = allItemCount
            });
        }