Beispiel #1
0
        // GET api/<controller>
        public IHttpActionResult Get()
        {
            using (var vehiclesBusiness = new VehiclesBusiness())
            {
                List <Vehicles> vehicles = vehiclesBusiness.SelectAllVehicles();

                var content = new ResponseContent <Vehicles>(vehicles);

                return(new StandartResult <Vehicles>(content, Request));
            }
        }
Beispiel #2
0
        // DELETE api/<controller>/5
        public IHttpActionResult Delete(int id)
        {
            var content = new ResponseContent <Vehicles>(null);

            using (var vehiclesBusiness = new VehiclesBusiness())
            {
                content.Result = vehiclesBusiness.DeleteVehicleById(id) ? "1" : "0";

                return(new StandartResult <Vehicles>(content, Request));
            }
        }
Beispiel #3
0
        // GET api/<controller>/5
        public IHttpActionResult Get(int id)
        {
            using (var vehiclesBusiness = new VehiclesBusiness())
            {
                Vehicles        vehicle  = vehiclesBusiness.SelectVehicleById(id);
                List <Vehicles> vehicles = new List <Vehicles>();
                vehicles.Add(vehicle);

                var content = new ResponseContent <Vehicles>(vehicles);

                return(new StandartResult <Vehicles>(content, Request));
            }
        }
Beispiel #4
0
        public async Task <IHttpActionResult> Trucks([FromBody] string hash)
        {
            try
            {
                string token = await _hashHelper.GetHash();

                var vehiclesBusiness = new VehiclesBusiness();

                var vehiclesInRange = await vehiclesBusiness.GetVehicles(token);

                return(Ok(vehiclesInRange));
            }
            catch (Exception e)
            {
                return(InternalServerError(e));
            }
        }
Beispiel #5
0
        public async Task <IHttpActionResult> Post(LumoLocationDTO location)
        {
            try
            {
                string token = await _hashHelper.GetHash();

                var vehiclesBusiness = new VehiclesBusiness();

                var vehiclesInRange = await vehiclesBusiness.GetVehiclesInRange(token, location.Latitude, location.Longitude);

                return(Ok(vehiclesInRange));
            }
            catch (Exception e)
            {
                return(InternalServerError(e));
            }
        }
Beispiel #6
0
        // POST api/<controller>
        public IHttpActionResult Post([FromBody] Vehicles vehicles)
        {
            var content = new ResponseContent <Vehicles>(null);

            if (vehicles != null)
            {
                using (var vehiclesBusiness = new VehiclesBusiness())
                {
                    content.Result = vehiclesBusiness.InsertVehicle(vehicles) ? "1" : "0";

                    return(new StandartResult <Vehicles>(content, Request));
                }
            }

            content.Result = "0";

            return(new StandartResult <Vehicles>(content, Request));
        }
Beispiel #7
0
        // PUT api/<controller>/5
        public IHttpActionResult Put(int id, [FromBody] Vehicles vehicles)
        {
            var content = new ResponseContent <Vehicles>(null);

            if (vehicles != null)
            {
                using (var vehiclesBusiness = new VehiclesBusiness())
                {
                    vehicles.VehicleID = id;
                    content.Result     = vehiclesBusiness.UpdateVehicle(vehicles) ? "1" : "0";

                    return(new StandartResult <Vehicles>(content, Request));
                }
            }

            content.Result = "0";

            return(new StandartResult <Vehicles>(content, Request));
        }