public IHttpActionResult GetUbicacion([FromBody] LoginViewModel vm) { MaestroUbicacion m = new MaestroUbicacion(); UbicacionDTO u = m.GetUbicacion(vm.Email); return(Ok(u)); }
// ILocationListener is a way for the Service to subscribe for updates // from the System location Service public void OnLocationChanged(Location location) { try { if (location == null) { return; } UbicacionDTO coordenadasSubir = new UbicacionDTO(); coordenadasSubir.ID_Usuario_Ubicacion = Perfil_Login.miPerfil.ID_Login; coordenadasSubir.Latitud = (decimal)location.Latitude; coordenadasSubir.Longitud = (decimal)location.Longitude; coordenadasSubir.Velocidad = (decimal?)location.Speed; coordenadasSubir.Precision = (decimal)location.Accuracy; coordenadasSubir.Bearing = (decimal)location.Bearing; try { coordenadasSubir.Tiempo = HelperMethods.ConvertFromUnixTimestamp((location.Time / 1000) - 18000, true); } catch (Exception) { coordenadasSubir.Tiempo = " "; } Conexion_Web_Service._client.SubirCoordenadasEmpleadosAsync(coordenadasSubir.ID_Usuario_Ubicacion, coordenadasSubir.Latitud, coordenadasSubir.Longitud, coordenadasSubir.Velocidad, coordenadasSubir.Precision, coordenadasSubir.Bearing, coordenadasSubir.Tiempo); Conexion_Web_Service._client.SubirCoordenadasEmpleadosCompleted += _client_SubirCoordenadasEmpleadosCompleted; } catch (Exception) { return; } }
public CoordenadasModel(UbicacionDTO listaCoordenadas) { ID_Ubicacion = listaCoordenadas.ID_Coordenada; ID_usuario = listaCoordenadas.ID_Usuario_Ubicacion; Nombre_Completo = listaCoordenadas.Nombre_Usuario; Latitud = listaCoordenadas.Latitud; Longitud = listaCoordenadas.Longitud; Velocidad = listaCoordenadas.Velocidad; Precision = listaCoordenadas.Precision; Bearing = listaCoordenadas.Bearing; Tiempo = listaCoordenadas.Tiempo; Direccion = listaCoordenadas.Direccion; }
public async Task <IActionResult> Update(int id, UbicacionDTO ubicacion) { if (ModelState.IsValid) { ubicacion = await _ubicacionService.Update(this.Usuario, id, ubicacion); return(Ok(ubicacion)); } else { return(BadRequest(ModelState)); } }
public async Task <UbicacionDTO> Create(UsuarioDTO userLogged, UbicacionDTO dto) { var entity = _mapper.Map <Ubicacion>(dto); entity.Active = true; entity.CreationDate = DateTime.Now; entity.CreationUserId = userLogged.Id; entity.UpdateDate = DateTime.Now; entity.UpdateUserId = userLogged.Id; entity.IdEmpresa = userLogged.IdEmpresa; entity = await _ubicacionRepository.Insert(entity); return(_mapper.Map <UbicacionDTO>(entity)); }
public UbicacionDTO GetUbicacion(string email) { con.Open(); SqlCommand cmd = new SqlCommand(); SqlDataReader reader; cmd.CommandText = "SELECT " + " r.IdRegion,r.Descripcion as Region, " + " ci.CiuCod,ci.Descripcion as Ciudad, " + " com.ComCod,com.Descripcion as Comuna " + "FROM Cliente C " + "INNER JOIN REGION R " + "ON R.IdRegion = C.IdRegion " + "INNER JOIN Ciudad CI " + "ON CI.CiuCod = C.CiuCod " + "INNER JOIN COMUNA COM " + "ON COM.ComCod = C.ComCod " + "WHERE C.Email = '" + email + "'"; cmd.CommandType = CommandType.Text; cmd.Connection = con; reader = cmd.ExecuteReader(); UbicacionDTO item = new UbicacionDTO(); while (reader.Read()) { item.Region = new RegionDTO { IdRegion = Convert.ToInt32(reader["IdRegion"]), Descripcion = reader["Region"].ToString() }; item.Ciudad = new CiudadDTO { CiuCod = reader["CiuCod"].ToString(), Descripcion = reader["Ciudad"].ToString() }; item.Comuna = new ComunaDTO { ComCod = reader["ComCod"].ToString(), Descripcion = reader["Comuna"].ToString() }; } reader.Close(); con.Close(); return(item); }
public async Task <UbicacionDTO> Update(UsuarioDTO loggedUser, int id, UbicacionDTO dto) { var entity = _mapper.Map <Ubicacion>(dto); if (entity.IdEmpresa == loggedUser.IdEmpresa) { entity.UpdateDate = DateTime.Now; entity.UpdateUserId = loggedUser.Id; var original = await _ubicacionRepository.GetById(id); entity.CreationDate = original.CreationDate; entity.CreationUserId = original.CreationUserId; entity.Active = original.Active; entity = await _ubicacionRepository.Update(id, entity); return(_mapper.Map <UbicacionDTO>(entity)); } else { return(null); } }