/// <summary> /// Busca dados da api externa e salva os dados no banco de dados /// </summary> /// <param name="retroactMonth">quantidade de meses a buscar na api externa</param> private void GetAllDataExternalAndSaveUpdateData(int retroactMonth) { DateTime from = DateTime.Now.AddMonths(-retroactMonth); DateTime to = DateTime.Now; Consume.Consume consume = new Consume.Consume(); var data = consume.GetAllDataByCountry(from, to, "Brazil"); ControllerResultConsumeApiExternal controllerResultConsumeApiExternal = new ControllerResultConsumeApiExternal(); controllerResultConsumeApiExternal.SaveData(data.ToList().ToList()); }
public virtual ActionResult <IList <AverageBean> > ListAvarage(int weeks) { try { ControllerResultConsumeApiExternal controllerResultConsumeApiExternal = new ControllerResultConsumeApiExternal(); return(controllerResultConsumeApiExternal.GetAverages(weeks)); } catch (Exception e) { return(new ObjectResult(null) { StatusCode = (int)HttpStatusCode.InternalServerError, Value = e.Message }); } }