コード例 #1
0
        public ActionResult Editar(int id, string callBack = "SetCargo")
        {
            try
            {
                ViewBag.CallBack = callBack;

                _cargoLogica = new CargoLogica();
                Cargo model = _cargoLogica.Buscar(id);

                return(PartialView("_Editar", model));
            }
            catch (Exception ex)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                ViewBag.Message     = ex.Message;
                return(PartialView("_Error"));
            }
        }
コード例 #2
0
 public ActionResult Listar()
 {
     try
     {
         _cargoLogica = new CargoLogica();
         List <Cargo> lista     = _cargoLogica.Listar() ?? new List <Cargo>();
         string       respuesta = JsonConvert.SerializeObject(lista.Select(x => new
         {
             x.Id,
             x.Codigo,
             x.Descripcion,
             x.Activo
         }));
         return(Content(respuesta, "application/json"));
     }
     catch (Exception ex)
     {
         Response.StatusCode = (int)HttpStatusCode.BadRequest;
         ViewBag.Message     = ex.Message;
         return(PartialView("_Error"));
     }
 }
コード例 #3
0
 public ActionResult Editar(Cargo model)
 {
     try
     {
         Validar(model);
         if (ModelState.IsValid)
         {
             _cargoLogica = new CargoLogica();
             _cargoLogica.Actualizar(model);
             return(Content(model.Id.ToString()));
         }
         else
         {
             Response.StatusCode = (int)HttpStatusCode.BadRequest;
             return(PartialView("_Error"));
         }
     }
     catch (Exception ex)
     {
         Response.StatusCode = (int)HttpStatusCode.BadRequest;
         ViewBag.Message     = ex.Message;
         return(PartialView("_Error"));
     }
 }