public ActionResult AdicionarVersaoBase() { try { fn = new FindBusEntities(); string versao = Request.Form["versao"]; tblBase novabase = (from bas in fn.tblBase where bas.VersaoBase.Contains(versao) select bas).FirstOrDefault <tblBase>(); if (novabase == null) { var path = Path.Combine(Server.MapPath("~/Mobile/Data/"), Request.Form["versao"].ToString()); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } new VersaoBase().GerarBaseDados(path); fn.tblBase.Add(new tblBase() { VersaoBase = Request.Form["versao"].ToString(), LocalBase = string.Format(@"/Mobile/Data/{0}/{1}", Request.Form["versao"].ToString(), "data.json"), DataInclusaoRegistro = DateTime.Now }); fn.SaveChanges(); return(Json("Versão de Base Inserida com Sucesso")); } else { return(Json("Versão de Base Já Existente!")); } } catch (Exception ex) { return(Json(ex.Message.ToString())); } }
public ActionResult RetornaVersaoApp() { using (fn = new FindBusEntities()) { var versaoAtual = (from ver in fn.tblVersao join app in fn.tblAplicativo on ver.AplicativoID equals app.AplicativoID select new { VersaoAPK = app.LocalAPK } ).FirstOrDefault(); if (versaoAtual != null) { return(new FileStreamResult(new FileStream(string.Format("{0}{1}", Server.MapPath("/"), versaoAtual.VersaoAPK), FileMode.Open), "application/vnd.android.package-archive") { FileDownloadName = "FindBus.apk" }); } else { return(RedirectToAction("Index", "Home")); } } }
public ActionResult AdicionarVersaoApp() { if (Session["CriaUsuario"] != null) { try { fn = new FindBusEntities(); string versao = Request.Form["versao"]; tblAplicativo novabase = (from bas in fn.tblAplicativo where bas.VersaoAplicativo.Contains(versao) select bas).FirstOrDefault <tblAplicativo>(); if (novabase == null) { HttpPostedFileBase baseFile = Request.Files[0]; if (baseFile != null && baseFile.ContentLength > 0) { var fileName = Path.GetFileName(baseFile.FileName); var path = Path.Combine(Server.MapPath("~/Mobile/App/"), Request.Form["versao"].ToString()); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } baseFile.SaveAs(string.Format("{0}/{1}", path, fileName)); fn.tblAplicativo.Add(new tblAplicativo() { VersaoAplicativo = Request.Form["versao"].ToString(), LocalAPK = string.Format(@"/Mobile/App/{0}/{1}", Request.Form["versao"].ToString(), fileName), DataInclusaoRegistro = DateTime.Now }); fn.SaveChanges(); } return(Json("Versão do App Inserida com Sucesso")); } else { return(Json("Versão do App Já Existente!")); } } catch (Exception ex) { return(Json(ex.Message.ToString())); } } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult Index() { if (Session["CriaUsuario"] != null) { fn = new FindBusEntities(); versoesBase = new List <VersaoApp>(); foreach (tblAplicativo vapp in fn.tblAplicativo.ToList()) { versoesBase.Add(new VersaoApp() { AppID = vapp.AplicativoID, versaoApp = vapp.VersaoAplicativo, Localapp = vapp.LocalAPK, DataInclusaoRegistro = vapp.DataInclusaoRegistro }); } return(View(versoesBase)); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult Index() { if (Session["CriaUsuario"] != null) { fn = new FindBusEntities(); versoesBase = new List <VersaoBase>(); foreach (tblBase vbase in fn.tblBase.ToList()) { versoesBase.Add(new VersaoBase() { BaseID = vbase.BaseID, versaoBase = vbase.VersaoBase, LocalBase = vbase.LocalBase, DataInclusaoRegistro = vbase.DataInclusaoRegistro }); } return(View(versoesBase)); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult InserirRota(List <PontoLocalizacao> pontos, string NomeRota) { if (pontos != null) { using (FindBusEntities fn = new FindBusEntities()) { var pontosRota = (from p in fn.tblRotaPonto where p.tblRota.Descricao.Equals(NomeRota) select p).ToList <tblRotaPonto>(); foreach (tblRotaPonto rotaponto in pontosRota) { fn.tblRotaPonto.Remove(rotaponto); } fn.SaveChanges(); } foreach (PontoLocalizacao ponto in pontos) { Localizacao localizacao = new Localizacao(ponto.Latitude, ponto.Longitude); localizacao.InserirLocalizacao(ponto, NomeRota); } } return(Json("Rota Inserida Com Sucesso!")); }