public async Task CreateModule(ModuleApi module) { try { var result = await repo.CreateModuleAsync( ConvertModuleApiToModule(module)); } catch (Exception e) { } }
public ModuleApi ConvertModuleToModuleApi(Module dataModel) { ModuleApi api = new ModuleApi(); api.Author = dataModel.Author; api.CourseIds = dataModel.CourseIds; api.Layout = dataModel.Layout; api.Title = dataModel.Title; api.ModuleId = dataModel.ModuleId; return(api); }
public Module ConvertModuleApiToModule(ModuleApi api) { Module dataModel = new Module(); dataModel.Author = api.Author; dataModel.CourseIds = api.CourseIds; dataModel.Layout = api.Layout; dataModel.Title = api.Title; dataModel.ModuleId = api.ModuleId; return(dataModel); }
public ActionResult Query(int moduleid, string modulename, 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)); var data = doverApi.GetModuleData(module, id, Request.QueryString); ModRepository.IncrementModuleRequestCount(module.Id); return(View(data)); }
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 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")); }
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")); }
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)); }
public async Task PutAsync(int id, [FromBody] ModuleApi module) { await repository.UpdateModule(module); }
public async Task PostAsync([FromBody] ModuleApi module) { await repository.CreateModule(module); }
public async Task UpdateModule(ModuleApi api) { await repo.UpdateModuleAsync( api.ModuleId, ConvertModuleApiToModule(api)); }
public static void Main(string[] args) { // add initial fake data for testing CourseApi course1 = new CourseApi { CourseId = "1", Name = "John Doe's course", ModuleIds = new List <string> { "987" } }; ModuleApi module1 = new ModuleApi { ModuleId = "987", Author = "John Doe", Title = "Agile Development", CourseIds = new List <string> { "1" }, Layout = new List <ModuleBaseContent> { new ModuleTextContent { Heading = "Motivation for Agile", Text = "This is why we want to do Agile" }, new ModuleImageContent { Link = "MyImageLink", Caption = "MyImageCaption" }, new ModuleVideoContent { Link = "MyVideoLink", Caption = "MyVideoCaption" }, new ModuleQuizContent { Link = "MyQuizLink" } } }; var host = BuildWebHost(args); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { IModuleRepository moduleRepository = services.GetRequiredService <IModuleRepository>(); moduleRepository.CreateModule(module1); ICourseRepository courseRepository = services.GetRequiredService <ICourseRepository>(); courseRepository.CreateCourse(course1); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred while seeding the database."); } } host.Run(); }
public void Init() { instance = new ModuleApi(); }