Beispiel #1
0
        public ActionResult module(int moduleid, int? id)
        {
            var doverApi = new ModuleApi(ModRepository);

            var module = ModRepository.GetModuleById(moduleid,
                m => m.Fields.Include<Field, FieldDataType>(f => f.FieldDataType),
                m => m.Rows.Include<Row, Cell>(r => r.Cells));

            if (module == null) {
                return View();
            }

            var data = doverApi.GetModuleData(module, id, Request.QueryString);

            ModRepository.IncrementModuleRequestCount(module.Id);

            return View(data);
        }
Beispiel #2
0
        public ActionResult module(int moduleid, DynamicModuleViewModel _entryToCreate)
        {
            var doverApi = new ModuleApi(ModRepository);
            var module = ModRepository.GetModuleById(moduleid, m => m.Fields);
            var result = String.Empty;
            var filteredList = new DynamicModuleFieldList();

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

            try {
                doverApi.CreateModule(module, _entryToCreate);
                result = "<result>Success</result>";
            }
            catch (CreateModuleFailedException) {
                result = "<result>Failure</result>";
            }

            return Content(result, "text/xml", Encoding.UTF8);
        }
        public ActionResult Create(object module, DynamicModuleViewModel _entryToCreate)
        {
            if(!ModelState.IsValid) {
                return View(_entryToCreate);
            }

            var newModule = module as Module;

            try {
                var moduleApi = new ModuleApi(ModRepository);
                moduleApi.CreateModule(newModule, _entryToCreate);
            }
            catch (CreateModuleFailedException e) {
                TempData["Message"] = e.Message;
                return View(_entryToCreate);
            }

            TempData["Message"] = "Registro criado com sucesso.";

            return (newModule.ModuleType == (int)ModuleType.Dynamic)
                ? RedirectToAction("List")
                : RedirectToAction("Index", "Home");
        }
Beispiel #4
0
        public ActionResult modules(string moduleid)
        {
            var dataList = new DynamicModuleApiResultList();

            if (!String.IsNullOrWhiteSpace(moduleid) &&
                Request.QueryString.Count == 0) {

                var doverApi = new ModuleApi(ModRepository);

                string[] ids = moduleid.Split(",".ToCharArray());

                foreach (var id in ids) {
                    int nid;
                    if (!Int32.TryParse(id.Trim(), out nid)) {
                        continue;
                    }

                    var module = ModRepository.GetModuleById(nid,
                        m => m.Fields.Include<Field, FieldDataType>(f => f.FieldDataType),
                        m => m.Rows.Include<Row, Cell>(r => r.Cells));

                    if (module == null) {
                        continue;
                    }

                    dataList.Add(doverApi.GetModuleData(module, null, Request.QueryString));

                    ModRepository.IncrementModuleRequestCount(module.Id);
                }
            }

            return View(dataList);
        }
Beispiel #5
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");
        }