public async Task <List <FuelTank> > GetFuelTanksList(int id) { ListFuelTanksRequestModel model = new ListFuelTanksRequestModel { Accion = "listar", Inicio = 0, Qty = 50, EquipoId = id, }; var response = await _cintelinkRest.GetFuelTanks(model); return(response.Select(x => new FuelTank() { Cant = x.cantidad, Capacity = x.capacidad, Description = x.descripcion, DescriptionTank = x.tanque_descripcion, Equipment = x.equipo, EquipmentId = x.id_equipo, Product = x.producto, ProductName = x.nombre_producto, Quantity = x.cantidad, Tank = x.tanque, TankId = x.id_tanque, Last_Date = x.ultima_fecha, Last_Quantity = x.ultima_cantidad }).ToList()); }
public async Task <List <ListFuelTanksResponseModel.Row> > GetFuelTanks(ListFuelTanksRequestModel model) { List <Parameter> listParameter = new List <Parameter>(); #region parameters Parameter action = new Parameter { Name = "accion", Value = model.Accion }; listParameter.Add(action); Parameter inicio = new Parameter { Name = "inicio", Value = model.Inicio.ToString() }; listParameter.Add(inicio); Parameter qty = new Parameter { Name = "qty", Value = model.Qty.ToString() }; listParameter.Add(qty); Parameter token = new Parameter { Name = "token", Value = await GetToken() }; listParameter.Add(token); Parameter Pfusr = new Parameter { Name = "pfusr", Value = await GetUserId() }; listParameter.Add(Pfusr); Parameter EquipoId = new Parameter { Name = "id_equipo", Value = model.EquipoId.ToString() }; listParameter.Add(EquipoId); #endregion string url = BaseWebApiURL.AddParametersList("", listParameter); var request = new HttpRequestMessage() { RequestUri = new Uri(BaseWebApiURL.BASE_URL + BaseWebApiURL.FUEL_TANK), Method = HttpMethod.Post, Content = new StringContent(url, Encoding.UTF8, "application/x-www-form-urlencoded") }; request.Headers.Add("Cookie", await GetCookie()); try { var response = await _httpClient.SendAsync(request); var loginJson = await response.Content.ReadAsStringAsync(); var convertModel = JsonConvert.DeserializeObject <ListFuelTanksResponseModel.Main>(loginJson); var modelresponse = convertModel.data.rows; return(modelresponse.ToList()); } catch (Exception e) { return(new List <ListFuelTanksResponseModel.Row>()); } }