Example #1
0
        public async Task <IActionResult> AddStation(AddStationDTO request)
        {
            ServiceResponse <List <Station> > response = await _routeService.AddStation(request);

            if (!response.Success)
            {
                return(BadRequest(response));
            }
            return(Ok(response));
        }
Example #2
0
        public async Task <ServiceResponse <List <Station> > > AddStation(AddStationDTO station)
        {
            ServiceResponse <List <Station> > response = new ServiceResponse <List <Station> >();

            try
            {
                await _context.Stations.AddAsync(new Station { Name = station.Name, Address = station.Address, XCoordinate = station.XCoordinate, YCoordinate = station.YCoordinate });

                await _context.SaveChangesAsync();

                response.Data = await _context.Stations.ToListAsync();
            }
            catch (Exception e)
            {
                response.Success = false;
                response.Message = e.Message;
            }
            return(response);
        }