Ejemplo n.º 1
0
 public ResultTransactionModel GetLocations(Vehicle vehicle, out GetLocationModel model)
 {
     try
     {
         GetLocationModel modelTem = new GetLocationModel();
         modelTem.locations = new List <Location>();
         conn.Open();
         var command = conn.CreateCommand();
         command.CommandText = "[GetVehicleLocation]";
         command.CommandType = CommandType.StoredProcedure;
         DbParameter vehicleId = command.CreateParameter();
         vehicleId.ParameterName = "@vehicleId";
         vehicleId.Value         = vehicle.vehicleId;
         command.Parameters.Add(vehicleId);
         DbDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
         while (reader.Read())
         {
             DateTime datetime = Convert.ToDateTime(reader["datetime"]);
             string[] location = Convert.ToString(reader["location"]).Split(' ');
             modelTem.locations.Add(new Location()
             {
                 datetime = datetime, latitud = location[0], longitud = location[1]
             });
         }
         model = modelTem;
         return(new ResultTransactionModel()
         {
             numAffactedRows = null, Description = null
         });
     }
     finally {
         conn.Close();
     }
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetLocationForUpdate(string Name)
        {
            string userid = User.Claims.First(c => c.Type == "UserId").Value;
            var    user   = await _userManager.FindByIdAsync(userid);

            var location = _db.LocationInfos.Where(x => x.Owner.UserName == user.UserName).ToList();

            foreach (LocationInfo Locate in location)
            {
                if (Locate.Name == Name)
                {
                    Result = Locate;
                    break;
                }
            }
            GetLocationModel locationModel = new GetLocationModel
            {
                CityName     = Result.District.city.CityName,
                DistrictName = Result.District.DistrictName,
                Menu         = Result.Menu,
                Type         = Result.Type,
                Name         = Result.Name
            };

            return(Ok(locationModel));
        }
Ejemplo n.º 3
0
        public void GetCurrentLocationTest()
        {
            var updateLocationModel = new GetLocationModel
            {
                vehicle = new Vehicle {
                    vehicleId = "AAA-AAA"
                }
            };
            VahicleController vehicleController = new VahicleController(repository);

            vehicleController.Request = new HttpRequestMessage();
            vehicleController.Request.SetConfiguration(new HttpConfiguration());
            var result = vehicleController.GetCurrectLocation(updateLocationModel);
        }
Ejemplo n.º 4
0
        public HttpResponseMessage GetLocations(GetLocationModel request)
        {
            var resultado = repository.GetLocations(request.vehicle, out request);

            return(Request.CreateResponse(HttpStatusCode.OK, new { resultado = resultado, data = request }));
        }