public PreAccoppiatiResult GetMarkerFromId(FiltriComposizionePartenza filtro) { var query = new PreAccoppiatiQuery() { Filtro = filtro }; return(handler.Handle(query)); }
public List <PreAccoppiatiFakeJson> GetFake(PreAccoppiatiQuery query) { var preAccoppiati = new List <PreAccoppiatiFakeJson>(); string filepath = "Fake/PreAccoppiatiComposizione.json"; string json; using (var r = new StreamReader(filepath)) { json = r.ReadToEnd(); } preAccoppiati = JsonConvert.DeserializeObject <List <PreAccoppiatiFakeJson> >(json); return(preAccoppiati.Where(x => query.CodiceSede.Contains(x.CodiceSede)).ToList()); }
public List <PreAccoppiati> Get(PreAccoppiatiQuery query) { List <PreAccoppiati> preAccoppiati = new List <PreAccoppiati>(); string filepath = "Fake/PreAccoppiatiComposizione.json"; string json; using (StreamReader r = new StreamReader(filepath)) { json = r.ReadToEnd(); } preAccoppiati = JsonConvert.DeserializeObject <List <PreAccoppiati> >(json); return(preAccoppiati.Where(x => x.CodiceSede == query.CodiceSede).ToList()); }
public List <PreAccoppiatiFakeJson> GetFake(PreAccoppiatiQuery query) { var preAccoppiati = new List <PreAccoppiatiFakeJson>(); string filepath = "Fake/PreAccoppiatiComposizione.json"; string json; using (StreamReader r = new StreamReader(filepath)) { json = r.ReadToEnd(); } preAccoppiati = JsonConvert.DeserializeObject <List <PreAccoppiatiFakeJson> >(json); return(preAccoppiati .Where(x => query.CodiceSede.Contains(x.CodiceSede)) .Where(c => { if (c.MezzoComposizione.Mezzo.IdRichiesta != null) { return c.MezzoComposizione.Mezzo.IdRichiesta == query.Filtri.IdRichiesta; } return true; }) .Where(c => { if (query.Filtri.StatoMezzo != null) { return query.Filtri.StatoMezzo.Contains(c.MezzoComposizione.Mezzo.Stato); } return true; }).Where(c => { if (query.Filtri.TipoMezzo != null) { return query.Filtri.TipoMezzo.Contains(c.MezzoComposizione.Mezzo.Genere); } return true; }).Where(c => { if (query.Filtri.CodiceDistaccamento != null) { return query.Filtri.CodiceDistaccamento.Contains(c.MezzoComposizione.Mezzo.Distaccamento.Codice); } return true; }).ToList()); }
public async Task <IActionResult> Get() { var codiceSede = Request.Headers["codicesede"]; var query = new PreAccoppiatiQuery() { CodiceSede = codiceSede }; try { return(Ok(_handler.Handle(query).preAccoppiati)); } catch { return(BadRequest()); } }
public async Task <List <PreAccoppiati> > GetAsync(PreAccoppiatiQuery query) { List <PreAccoppiati> ListaPreAccoppiati = new List <PreAccoppiati>(); string CodSede = query.CodiceSede.Substring(0, 2); if (!_memoryCache.TryGetValue("ListaPreAccoppiati", out ListaPreAccoppiati)) { #region LEGGO DA API ESTERNA //_client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("test"); //var response = await _client.GetAsync($"{_configuration.GetSection("DataFakeImplementation").GetSection("UrlAPIPreAccoppiati").Value}/GetListaPreaccoppiatiByCodComando?CodComando={CodSede}").ConfigureAwait(false); //response.EnsureSuccessStatusCode(); //using HttpContent content = response.Content; //string data = await content.ReadAsStringAsync().ConfigureAwait(false); //var ListaPreAccoppiatiFake = JsonConvert.DeserializeObject<List<PreAccoppiatiFake>>(data); #endregion LEGGO DA API ESTERNA #region LEGGO DA JSON FAKE var filepath = Costanti.ListaPreAccoppiati; string json; using (var r = new StreamReader(filepath)) { json = r.ReadToEnd(); } var listaPreaccoppiati = JsonConvert.DeserializeObject <List <PreAccoppiatiFake> >(json); var ListaPreAccoppiatiFake = listaPreaccoppiati.FindAll(x => x.Sede.Split('.')[0].Equals(CodSede)); #endregion LEGGO DA JSON FAKE ListaPreAccoppiati = MapPreAccoppiati(ListaPreAccoppiatiFake); var cacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromHours(2)); _memoryCache.Set("ListaPreAccoppiati", ListaPreAccoppiati, cacheEntryOptions); } return(ListaPreAccoppiati); }
public async Task <IActionResult> Post(FiltriPreaccoppiati filtri) { var query = new PreAccoppiatiQuery() { CodiceSede = Request.Headers["CodiceSede"].ToArray(), IdUtente = Request.Headers["IdUtente"].ToString(), Filtri = filtri }; try { return(Ok(_handler.Handle(query))); } catch (Exception ex) { if (ex.Message.Contains(Costanti.UtenteNonAutorizzato)) { return(StatusCode(403, new { message = Costanti.UtenteNonAutorizzato })); } return(BadRequest(new { message = ex.Message })); } }
public async Task <List <PreAccoppiati> > GetAsync(PreAccoppiatiQuery query) { List <PreAccoppiati> ListaPreAccoppiati = new List <PreAccoppiati>(); string CodSede = query.CodiceSede.FirstOrDefault().Substring(0, 2); if (!_memoryCache.TryGetValue("ListaPreAccoppiati", out ListaPreAccoppiati)) { _client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("test"); var response = await _client.GetAsync($"{_configuration.GetSection("OracleImplementation").GetSection(CodSede).GetSection("UrlAPISquadre").Value}/GetListaGesPreaccoppiati?CodSede={CodSede}").ConfigureAwait(false); response.EnsureSuccessStatusCode(); using HttpContent content = response.Content; string data = await content.ReadAsStringAsync().ConfigureAwait(false); List <ORAGesPreaccoppiati> ListaPreAccoppiatiOracle = JsonConvert.DeserializeObject <List <ORAGesPreaccoppiati> >(data); ListaPreAccoppiati = MapListaPreAccoppiatiOraInMongoDB(ListaPreAccoppiatiOracle); var cacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromHours(2)); _memoryCache.Set("ListaPreAccoppiati", ListaPreAccoppiati, cacheEntryOptions); } return(ListaPreAccoppiati); }
public async Task <IActionResult> Get() { var codiceSede = Request.Headers["codicesede"]; var query = new PreAccoppiatiQuery() { CodiceSede = codiceSede }; try { return(Ok(_handler.Handle(query).preAccoppiati)); } catch (Exception ex) { if (ex.Message.Contains(Costanti.UtenteNonAutorizzato)) { return(StatusCode(403, Costanti.UtenteNonAutorizzato)); } return(BadRequest()); } }
public async Task <IActionResult> Post(FiltriComposizionePartenza filtri) { var headerValues = Request.Headers["HubConnectionId"]; string ConId = headerValues.FirstOrDefault(); var query = new PreAccoppiatiQuery() { Filtro = filtri }; try { List <PreAccoppiati> preAccoppiati = new List <PreAccoppiati>(); preAccoppiati = handler.Handle(query).PreAccoppiati; await _NotificationHub.Clients.Client(ConId).SendAsync("NotifyGetPreAccoppiati", preAccoppiati); return(Ok()); } catch { return(BadRequest()); } }
public List <PreAccoppiati> Get(PreAccoppiatiQuery query) { return(GetAsync(query).Result); }
public List <PreAccoppiatiFakeJson> GetFake(PreAccoppiatiQuery query) { throw new NotImplementedException(); }