public async Task <ResourceDataResult> UpdateStop(int stopId, StopForUpdateDTO stopModel)
        {
            ResourceDataResult result = new ResourceDataResult();

            var stop = await _stopRepo.GetStopById(stopId);

            //upsert
            if (stop == null)
            {
                result.StatusCode = 201;
                stop = new Stop()
                {
                    Id = stopId
                };
            }

            stop = StopMapper.UpdateEntityToModel(stop, stopModel);

            if (stop != null && await _stopRepo.UpdateStop(stop))
            {
                result.Result = StopMapper.ConvertEntityToModel(stop);
                return(result);
            }

            return(null);
        }
        public void TestInitialize()
        {
            MockDatabase = new Mock <IDatabase>();
            MockQuery    = new Mock <IQuery>();
            MockHydrater = new Mock <IHydrater <StopVO> >();

            Target = new StopMapper(MockDatabase.Object, MockHydrater.Object);

            MockDatabase.Setup(m => m.CreateQuery(It.IsAny <string>())).Returns(MockQuery.Object);
        }
        public async Task <StopDTO> CreateStop(StopForCreationDTO stopModel)
        {
            Stop stop = StopMapper.ConvertCreationModelToEntity(stopModel);

            if (await _stopRepo.CreateStop(stop))
            {
                return(StopMapper.ConvertEntityToModel(stop));
            }

            return(null);
        }
        public async Task <IEnumerable <StopDTO> > GetStops(IEnumerable <int> ids)
        {
            var stops = await _stopRepo.GetStops(ids);

            if (stops != null)
            {
                return(StopMapper.ConvertEntityToModel(stops));
            }

            return(null);
        }
        public async Task <StopDTO> GetStop(int stopId)
        {
            var stop = await _stopRepo.GetStopById(stopId);


            if (stop != null)
            {
                return(StopMapper.ConvertEntityToModel(stop));
            }

            return(null);
        }
        public async Task <StopForUpdateDTO> GetUpdateModelForStop(int stopId)
        {
            var stop = await _stopRepo.GetStopById(stopId);

            if (stop == null)
            {
                return(null);
            }

            StopForUpdateDTO updatedStop = StopMapper.ConvertEntityToModel <StopForUpdateDTO>(stop);

            return(updatedStop);
        }
        public BusStopDataModel JoinBusStopData(List <BusStopData> busStopDataList)
        {
            var firstResult = busStopDataList.FirstOrDefault();
            var stopList    = busStopDataList.SelectMany(x => x.Stops)
                              .GroupBy(x => new
            {
                x.StopId,
                x.StopLat,
                x.StopLon,
                x.StopDesc
            })
                              .Select(x => x.FirstOrDefault())
                              .ToList();

            return(new BusStopDataModel
            {
                Day = firstResult.Day,
                LastUpdate = firstResult.LastUpdate,
                Stops = StopMapper.GetMappedStopList(stopList)
            });
        }
        public async Task <ResourceDataResult> GetStops(PaginationProperties paginationProperties)
        {
            ResourceDataResult result = new ResourceDataResult();

            if (!_sortPropertyMappingService.ValidMappingExistsFor <StopDTO, Stop>(paginationProperties.OrderBy))
            {
                result.StatusCode   = 400;
                result.ErrorMessage = "Invalid sorting field in query string.";
                return(result);
            }

            PagedList <Stop> stops = await _stopRepo.GetStops(paginationProperties);

            //PagedList<StopDTO> stopModels = new PagedList<StopDTO>(StopMapper.ConvertEntityToModel(stops), stops.Count, stops.CurrentPage, stops.PageSize);

            if (stops != null && stops.Count > 0)
            {
                result.Result = new PagedList <StopDTO>(StopMapper.ConvertEntityToModel(stops), stops.TotalCount, stops.CurrentPage, stops.PageSize);
            }

            return(result);
        }
Esempio n. 9
0
 public void TestCleanup()
 {
     Target = null;
 }
Esempio n. 10
0
 public void TestInitialize()
 {
     Target = new StopMapper();
 }