public ActionResult AdicionarEditar(Circuito emp)
 {
     try
     {
         if (emp.ImagemUpload != null)
         {
             string fileName  = Path.GetFileNameWithoutExtension(emp.ImagemUpload.FileName);
             string extension = Path.GetExtension(emp.ImagemUpload.FileName);
             fileName   = fileName + DateTime.Now.ToString("yymmssfff") + extension;
             emp.Imagem = "~/Content/Imagens/" + fileName;
             emp.ImagemUpload.SaveAs(Path.Combine(Server.MapPath("~/Content/Imagens/"), fileName));
         }
         using (FormulaIFSContext db = new FormulaIFSContext())
         {
             if (emp.Id == 0)
             {
                 db.Circuitos.Add(emp);
                 db.SaveChanges();
             }
             else
             {
                 db.Entry(emp).State = EntityState.Modified;
                 db.SaveChanges();
             }
         }
         return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "Visao", GetCircuitos()), message = "Salvo com Sucesso" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
        public ActionResult Criar([Bind(Include = "Id,Nome,Vinculo,Email,Login")] Usuario usuario)
        {
            if (ModelState.IsValid)
            {
                db.Usuarios.Add(usuario);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(usuario));
        }
 public ActionResult AdicionarEditar(Categoria emp)
 {
     try
     {
         using (FormulaIFSContext db = new FormulaIFSContext())
         {
             if (emp.Id == 0)
             {
                 db.Categorias.Add(emp);
                 db.SaveChanges();
             }
             else
             {
                 db.Entry(emp).State = EntityState.Modified;
                 db.SaveChanges();
             }
         }
         return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "Visao", GetCategorias()), message = "Salvo com Sucesso" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult Delete(int id)
 {
     try
     {
         using (FormulaIFSContext db = new FormulaIFSContext())
         {
             Categoria emp = db.Categorias.Where(x => x.Id == id).FirstOrDefault <Categoria>();
             db.Categorias.Remove(emp);
             db.SaveChanges();
         }
         return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "Visao", GetCategorias()), message = "Deletado com sucesso" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }