예제 #1
0
        public ActionResult Edit(TemplateFormViewModel model)
        {
            TemplateDto Template = serviceTemplate.GetItem(model.TemplateId);

            try
            {
                if (ModelState.IsValid)
                {
                    Template.TemplateId = model.TemplateId;

                    Template.Name      = model.Name;
                    Template.AdminView = model.AdminView;
                    Template.FrontView = model.FrontView;
                    Template.IsSection = model.IsSection;
                    Template.Active    = model.Active;

                    serviceTemplate.Edit(Template);
                }
                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"));
        }