Ejemplo n.º 1
0
        public ActionResult Create()
        {
            var model = new SchemaFormViewModel()
            {
                Active = true
            };

            ViewBag.TemplateList = serviceTemplate.GetList(SchemaParentId);
            //ViewBag.SchemaParentId = SchemaParentId;

            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult Create(SchemaFormViewModel model)
        {
            ViewBag.SchemaParentId = model.SchemaParentId;
            ViewBag.TemplateList   = serviceTemplate.GetList(model.SchemaParentId);

            try
            {
                if (ModelState.IsValid)
                {
                    serviceSchema.Add(new SchemaDto()
                    {
                        SchemaId       = model.SchemaId,
                        SchemaParentId = model.SchemaParentId,

                        //SectionId = model.SectionId,
                        TemplateId = model.TemplateId,
                        Iterations = model.Iterations,
                        Position   = model.Position,
                        IsPage     = model.IsPage,
                        Alias      = model.Alias,
                        Active     = model.Active
                    });
                }
                else
                {
                    ModelState.AddModelError("Error", "Algunos datos ingresados no son válidos");
                    return(View(model));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Error", "Se ha producido un error: " + ex.Message);
                return(View(model));
            }

            return(RedirectToAction("Index", new { SchemaId = ViewBag.SchemaId, SchemaParentId = ViewBag.SchemaParentId }));
        }
Ejemplo n.º 3
0
        public ActionResult Edit(SchemaFormViewModel model)
        {
            SchemaDto schema = serviceSchema.GetItem(model.SchemaId);

            ViewBag.SchemaParentId = schema.SchemaParentId;
            ViewBag.TemplateList   = serviceTemplate.GetList(schema.SchemaParentId);

            try
            {
                if (ModelState.IsValid)
                {
                    //schema.SectionId = model.SectionId;
                    schema.TemplateId = model.TemplateId;
                    schema.Iterations = model.Iterations;
                    schema.Position   = model.Position;
                    schema.IsPage     = model.IsPage;
                    schema.Alias      = model.Alias;
                    schema.Active     = model.Active;

                    serviceSchema.Edit(schema);
                }
                else
                {
                    ModelState.AddModelError("Error", "Algunos datos ingresados no son válidos");
                    return(View(model));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Error", "Se ha producido un error: " + ex.Message);
                return(View(model));
            }


            return(RedirectToAction("Index", new { SchemaId = ViewBag.SchemaId, SchemaParentId = ViewBag.SchemaParentId }));
        }