public List <CIDADE> CarregaMemoria() { List <CIDADE> Cidade = new List <CIDADE>(); try { EFContext dbs = new EFContext(); if (!dbs.Connexao()) { string Caminho = HttpContext.Current.Server.MapPath("~/Arquivos/Cidades.json"); string json = File.ReadAllText(Caminho); List <CidadeViewModel> Model = Newtonsoft.Json.JsonConvert.DeserializeObject <List <CidadeViewModel> >(json); Model.ForEach(x => Cidade.Add(x.toCreate())); return(Cidade); } else { return(Cidade); } } catch (Exception ex) { ex.Message.ToString(); } return(Cidade); }
public void Add(CIDADE Model) { if (dbs.Connexao()) { dbs.Cidade.Add(Model); dbs.SaveChanges(); } else { MvcApplication.CidadePublic.Add(Model); } }