//PUT api/onlinevehicle
        public HttpResponseMessage Put(OnlineVehicle onlineVehicle)
        {
            //check if the vehicle is online?
            OnlineVehicle ov = Uow.OnlineVehicles.GetAll().Where(o =>
                                                                 o.VehicleId == onlineVehicle.VehicleId).FirstOrDefault();

            if (ov == null) //we should add to the online vehicles
            {
                Uow.OnlineVehicles.Add(onlineVehicle);
                Uow.Commit();
            }
            else // we should update the online vehicle
            {
                ov.VehicleId  = onlineVehicle.VehicleId;
                ov.DriverId   = onlineVehicle.DriverId;
                ov.Lat        = onlineVehicle.Lat;
                ov.Lng        = onlineVehicle.Lng;
                ov.StatusId   = onlineVehicle.StatusId;
                ov.LastUpdate = onlineVehicle.LastUpdate;
                ov.JobId      = onlineVehicle.JobId;

                Uow.OnlineVehicles.Update(ov);
                Uow.Commit();
            }


            return(new HttpResponseMessage(HttpStatusCode.NoContent));
        }
Пример #2
0
 public void AcceptDecline([FromBody] OnlineVehicle onlineVehicle)
 {
     if (onlineVehicle != null)
     {
         Uow.OnlineVehicles.Update(onlineVehicle);
         Uow.Commit();
     }
 }
        //GET api/onlicevehicle/5
        public OnlineVehicle Get(int id)
        {
            OnlineVehicle onlineVehicle = Uow.OnlineVehicles.GetById(id);

            if (onlineVehicle == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(onlineVehicle);
        }