Esempio n. 1
0
 public async Task <ResponseDTO> RegisterCoordinates(RegisterLocationCoordinatesRequest locationCoordinates)
 {
     if (ModelState.IsValid)
     {
         return(await _locationApplicationService.RegisterLocationCoordinatesAsync(locationCoordinates));
     }
     return(ModelState.ToResponse());
 }
Esempio n. 2
0
        public async Task <ResponseDTO> RegisterLocationCoordinatesAsync(RegisterLocationCoordinatesRequest newCoordinates)
        {
            //Map to Command
            var command = _mapper.Map <RegisterLocationCoordinatesRequest, RegisterLocationCoordinatesCommand>(newCoordinates);

            //TODO FAVIO use mapper:
            command.RegisterLocationCoordinatesList = new List <Commands.Tracking.Location.RegisterLocationCoordinateItem>();
            foreach (var coordinate in newCoordinates.RegisterLocationCoordinateList)
            {
                command.RegisterLocationCoordinatesList.Add(new Commands.Tracking.Location.RegisterLocationCoordinateItem()
                {
                    Latitude     = coordinate.Latitude,
                    Longitude    = coordinate.Longitude,
                    LocationCode = coordinate.LocationCode
                });
            }


            //Execute Command
            var resp = await _bus.SendAsync(command);

            return(ResponseBuilder.Correct(resp));
        }
        public async Task RegisterLocationCoordinates_Call()
        {
            //--------------    Arrange     -------------
            CommonArrangements();

            var request = new RegisterLocationCoordinatesRequest();

            request.RegisterLocationCoordinateList = new List <Application.DTOs.Requests.Tracking.RegisterLocationCoordinateItem>();
            request.RegisterLocationCoordinateList.Add(new Application.DTOs.Requests.Tracking.RegisterLocationCoordinateItem()
            {
                Latitude = 1, Longitude = 2, LocationCode = "TEST"
            });

            var command = new RegisterLocationCoordinatesCommand();

            A.CallTo(() => mapper.Map <RegisterLocationCoordinatesRequest, RegisterLocationCoordinatesCommand>(request)).Returns(command);


            //--------------    Act     -------------
            var resp = locationService.RegisterLocationCoordinatesAsync(request);

            //--------------    Assert     -------------
            A.CallTo(() => bus.SendAsync(command)).MustHaveHappened(Repeated.Exactly.Once);
        }