コード例 #1
0
        public ActionResult DeleteInfante(int?id)
        {
            try
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                InfanteRepository InfanRepo = new InfanteRepository();
                if (InfanRepo.DeleteInfante(id))
                {
                    ViewBag.AlertMsg = "Infante eliminado";
                }
                else
                {
                    ViewBag.AlertMsg = "No se puedo eliminar";
                }

                return(RedirectToAction("GetInfantes"));
            }
            catch
            {
                return(RedirectToAction("GetInfantes"));
            }
        }
コード例 #2
0
        public ActionResult EditInfante(Infante obj)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    InfanteRepository InfanRepo = new InfanteRepository();
                    if (InfanRepo.UpdateInfante(obj))
                    {
                        ViewBag.Message = "Infante modificado";
                    }
                    else
                    {
                        ViewBag.Message = "Ocurrio un error";
                    }

                    return(RedirectToAction("GetInfantes"));
                }
                return(View(obj));
            }
            catch
            {
                return(RedirectToAction("GetInfantes"));
            }
        }
コード例 #3
0
        public ActionResult GetInfantes()
        {
            InfanteRepository InfanRepo = new InfanteRepository();

            ModelState.Clear();

            return(View(InfanRepo.ListarInfantes()));
        }
コード例 #4
0
        public ActionResult EditInfante(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            InfanteRepository InfanRepo = new InfanteRepository();
            Infante           result    = InfanRepo.ListarInfantes()
                                          .Find(Inf => Inf.Infante_ID == id);

            if (result == null)
            {
                return(HttpNotFound());
            }

            return(View(result));
        }
コード例 #5
0
 public ActionResult AddInfante(Infante inf)
 {
     try
     {
         if (ModelState.IsValid)
         {
             InfanteRepository InfanRepo = new InfanteRepository();
             if (InfanRepo.AddInfante(inf))
             {
                 ViewBag.Message = "Infante agregado";
             }
             else
             {
                 ViewBag.Message = "Ocurrio un error";
             }
         }
         return(RedirectToAction("GetInfantes"));
     }
     catch
     {
         return(View());
     }
 }