예제 #1
0
 public IActionResult NuevoAroma(AromasModelView model)
 {
     try
     {
         //llenar combo de status
         var sts = datos.TraerStatus();
         foreach (var st in sts)
         {
             model.StatusList.Add(new SelectListItem {
                 Value = st.status, Text = st.nombre, Selected = model.status.Trim() == st.status
             });
         }
         var res = datos.GuardarAroma(model, "N");
         if (res)
         {
             return(RedirectToAction("Aromas"));
         }
         else
         {
             return(View(model));
         }
     }
     catch (Exception ex)
     {
         ViewBag.Errores = ex.Message;
         return(View(model));
     }
 }
예제 #2
0
        public IActionResult EditarAroma(string id)
        {
            if (id == null)
            {
                return(BadRequest());
            }

            var aroma = datos.TraerAroma(id);

            if (aroma == null)
            {
                //ViewBagErrores = "No existe el aroma";
                return(NotFound());
            }
            var model = new AromasModelView()
            {
                aroma = aroma.aroma, nombre = aroma.nombre, abreviatura = aroma.abreviatura, status = aroma.status.Trim()
            };
            var sts = datos.TraerStatus();

            foreach (var st in sts)
            {
                model.StatusList.Add(new SelectListItem {
                    Value = st.status, Text = st.nombre, Selected = model.status.Trim() == st.status.Trim()
                });
            }
            return(View(model));
        }
예제 #3
0
        public IActionResult NuevoAroma()
        {
            var model = new AromasModelView();

            model.status = "V";
            var sts = datos.TraerStatus();

            foreach (var st in sts)
            {
                model.StatusList.Add(new SelectListItem {
                    Value = st.status, Text = st.nombre, Selected = model.status.Trim() == st.status
                });
            }
            return(View(model));
        }