public ActionResult Nuevo(Estructura model) { try { _estructuraLogica = new EstructuraLogica(); Validar(model); if (ModelState.IsValid) { if (model.Tablero && model.PadreId.HasValue && _estructuraLogica.TieneTablero(model.PadreId.Value)) { ModelState.AddModelError("Tablero", "No puede agregar un tablero dentro de otro."); } } if (ModelState.IsValid) { _estructuraLogica.Guardar(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")); } }
public ActionResult ModelarTablero(Estructura model) { try { Validar(model.Instancias, model.Areas); if (ModelState.IsValid) { if (model.Areas != null) { model.Areas.ForEach(x => x.EstructuraId = model.Id); } if (model.Instancias != null) { model.Instancias.ForEach(x => x.EstructuraId = model.Id); } _estructuraLogica = new EstructuraLogica(); _estructuraLogica.Guardar(model.Id, model.Instancias, model.Areas); return(Content("Se guardaron los cambios.")); } else { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(PartialView("_Error")); } } catch (Exception ex) { Response.StatusCode = (int)HttpStatusCode.BadRequest; ViewBag.Message = ex.Message; return(PartialView("_Error")); } }