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)); } }
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)); }
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)); }