Beispiel #1
0
 public void Post([FromBody] AddLocationDTO addLocation)
 {
     LocationTracker.WebApiApplication.Bus.Send("AddLocation", new AddLocationCommand()
     {
         Id          = addLocation.id,
         Latitude    = addLocation.latitude,
         Longitude   = addLocation.longitude,
         Description = addLocation.description,
         TimeStamp   = addLocation.timeStamp
     });
 }
Beispiel #2
0
        public async Task <ServiceResponse <List <GetLocationDTO> > > AddLocation(AddLocationDTO newLocation)
        {
            ServiceResponse <List <GetLocationDTO> > serviceResponse = new ServiceResponse <List <GetLocationDTO> >();
            Location l = _mapper.Map <Location>(newLocation);

            l.IsDeleted = false;
            if ((l.Capacity == 0) || (l.Address == null))
            {
                serviceResponse.Success = false;
                serviceResponse.Message = "Please enter sufficient data. Capacity or address is missing.";
                return(serviceResponse);
            }
            await _context.Locations.AddAsync(l);

            await _context.SaveChangesAsync();

            serviceResponse.Data = (_context.Locations.Select(e => _mapper.Map <GetLocationDTO>(l))).ToList();
            return(serviceResponse);
        }
 public async Task <IActionResult> Add(AddLocationDTO l)
 {
     return(Ok(await _locationService.AddLocation(l)));
 }