Esempio n. 1
0
 public ActionResult Delete(int id, FormCollection form)
 {
     try
     {
         if (ModelState.IsValid)
         {
             ServicesCidade objDB = new ServicesCidade();
             Cidade dto = new Cidade();
             dto.Id = id;
             if (objDB.Delete(dto))
                 return RedirectToAction("Index");
             else
             {
                 ViewData["Msg"] = "Erro ao excluir";
                 return View();
             }
         }
         else
         {
             ViewData["Msg"] = "Campos inválidos.";
             return View();
         }
     }
     catch (Exception ex)
     {
         Utils.Log.DoLog(ex, System.Diagnostics.EventLogEntryType.Error, "Delete", "CidadeController");
         ViewData["Msg"] = "Erro ao excluir";
         return View();
     }
 }
Esempio n. 2
0
 //
 // GET: /Cidade/Delete/5
 public ActionResult Delete(int id)
 {
     ServicesCidade objDB = new ServicesCidade();
     Cidade dto = new Cidade();
     dto.Id = id;
     return View(objDB.SelectOne(dto));
 }
Esempio n. 3
0
 public ActionResult Create(FormCollection Cidade)
 {
     try
     {
         if (ModelState.IsValid)
         {
             ServicesCidade objDB = new ServicesCidade();
             if (objDB.Insert(new Cidade(Cidade)))
                 return RedirectToAction("Index");
             else
             {
                 ViewData["Msg"] = "Erro ao incluir";
                 CarregaEstados();
                 return View();
             }
         }
         else
         {
             ViewData["Msg"] = "Campos inválidos.";
             CarregaEstados();
             return View();
         }
     }
     catch (Exception ex)
     {
         Utils.Log.DoLog(ex, System.Diagnostics.EventLogEntryType.Error, "Create", "CidadeController");
         ViewData["Msg"] = "Erro ao incluir";
         CarregaEstados();
         return View();
     }
 }
Esempio n. 4
0
 //
 // GET: /Cidade/
 public ActionResult Index()
 {
     ServicesCidade objDB = new ServicesCidade();
     Cidade dto = new Cidade();
     return View(objDB.SelectWhere(dto));
 }
Esempio n. 5
0
        //
        // GET: /Cidade/Edit/5
        public ActionResult Edit(int id)
        {
            ServicesCidade objDB = new ServicesCidade();
            Cidade dto = new Cidade();
            dto.Id = id;

            Cidade cidade = objDB.SelectOne(dto);

            CarregaEstados(cidade.Estado);

            return View(cidade);
        }
Esempio n. 6
0
 public JsonResult DeleteAjax(int id)
 {
     try
     {
         ServicesCidade objDB = new ServicesCidade();
         Cidade dto = new Cidade();
         dto.Id = id;
         if (objDB.Delete(dto))
             return Json(new { Result = "OK" });
         else
             return Json(new { Result = "ERROR", Message = "Erro ao excluir." });
     }
     catch (Exception ex)
     {
         return Json(new { Result = "ERROR", Message = ex.Message });
     }
 }