public async Task <IHttpActionResult> InvestigadoresHomeSYNC() { try { log.Info(new MDCSet(this.ControllerContext.RouteData)); var grafica = await _repository.GetInvestigadoresHome(); if (grafica != null && grafica.Datos != null && grafica.Datos.Count > 0) { try { log.Info(new MDCSet(this.ControllerContext.RouteData)); InvestigadoresHome model = new InvestigadoresHome(); model.Fecha = DateTime.Now; model.GraficaJson = new JavaScriptSerializer().Serialize(grafica); await _repository.CreateInvestigadoresHome(model); } catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e); } } return(Ok(grafica)); } catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e); return(InternalServerError(e)); } }
public async Task <IHttpActionResult> InvestigadoresHome() { try { log.Info(new MDCSet(this.ControllerContext.RouteData)); var result = await _repository.GetInvestigadoresCache(); var ok = false; Grafica grafica = null; if (result != null) { if (!String.IsNullOrEmpty(result.GraficaJson)) { grafica = new JavaScriptSerializer().Deserialize <Grafica>(result.GraficaJson); ok = true; } } if (!ok) { grafica = await _repository.GetInvestigadoresHome(); if (grafica != null) { try { log.Info(new MDCSet(this.ControllerContext.RouteData)); InvestigadoresHome model = new InvestigadoresHome(); model.Fecha = DateTime.Now; model.GraficaJson = new JavaScriptSerializer().Serialize(grafica); await _repository.CreateInvestigadoresHome(model); } catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e); } } } return(Ok(grafica)); } catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e); return(InternalServerError(e)); } }