Esempio n. 1
0
        //Editar
        public ActionResult Editar(int id)
        {
            var modalidad          = _ctx.Modalidades.Find(id);
            ModalidadViewModel mvm = new ModalidadViewModel(modalidad);

            return(View("FormModalidad", mvm));
        }
Esempio n. 2
0
 public ActionResult Crear(ModalidadViewModel mvm)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             //Algo estuvo mal.
             return(View("FormModalidad"));
         }
         if (mvm.Id == 0)
         {
             Modalidad m = new Modalidad();
             m.descripcion = mvm.descripcion;
             m.n_meses     = mvm.n_meses;
             m.n_periodos  = mvm.n_periodos;
             _ctx.Modalidades.Add(m);
         }
         else
         {
             //Estan editando
             var modalidadExistente = _ctx.Modalidades.SingleOrDefault(x => x.Id == mvm.Id);
             if (modalidadExistente != null)
             {
                 modalidadExistente.descripcion = mvm.descripcion;
                 modalidadExistente.n_meses     = mvm.n_meses;
                 modalidadExistente.n_periodos  = mvm.n_periodos;
             }
         }
     }
     catch
     {
         return(View());
     }
     _ctx.SaveChanges();
     return(RedirectToAction("Index"));
 }
Esempio n. 3
0
        public ActionResult Create()
        {
            ModalidadViewModel vm = new ModalidadViewModel();

            return(View("FormModalidad", vm));
        }