Example #1
0
        public ActionResult module(int moduleid, int? id, DynamicModuleViewModel _entryToEdit)
        {
            var result = String.Empty;

            try {
                var doverApi = new ModuleApi(ModRepository);
                var module = ModRepository.GetModuleById(moduleid, m => m.Rows.Include<Row, Cell>(r => r.Cells), m => m.Fields);
                var filteredList = new DynamicModuleFieldList();

                filteredList.AddRange(_entryToEdit.Fields.Where(f => CheckFieldExistency(f)));
                _entryToEdit.Fields = filteredList;

                doverApi.SetModuleData(module, id, _entryToEdit, true);
                result = "<result>Success</result>";
            }
            catch (Exception e) {
                result = "<result>Failure</result>";
            }

            return Content(result, "text/xml", Encoding.UTF8);
        }
        public ActionResult Edit(object module, int? id, DynamicModuleViewModel _entryToEdit)
        {
            if(!ModelState.IsValid) {
                return View(_entryToEdit);
            }

            var moduleToEdit = module as Module;

            try {
                var moduleApi = new ModuleApi(ModRepository);
                moduleApi.SetModuleData(moduleToEdit, id, _entryToEdit);
            }
            catch (ModuleRowNotFoundException e) {
                TempData["Message"] = e.Message;
                return this.RedirectToAction("List");
            }

            TempData["Message"] = "Seus dados foram salvos.";

            return (moduleToEdit.ModuleType == (int)ModuleType.Dynamic)
                ? RedirectToAction("List")
                : RedirectToAction("Index", "Home");
        }