public HttpResponseMessage Add(WikiAddRequest model) { // if the Model does not pass validation, there will be an Error response returned with errors if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } ItemResponse <int> response = new ItemResponse <int>(); string userId = UserService.GetCurrentUserId(); response.Item = _wikiService.Add(model, userId); return(Request.CreateResponse(response)); }
public int CreateSectionModule(SectionModule model) { int Id = 0; int moduleId = model.ModuleId; //Module oldModule = new Module(); if (model.ModuleId > 0) { Module oldModule = _moduleService.GetClassModules(moduleId); string name = oldModule.ModuleName; int sectionId = model.SectionId; ModuleAddRequest module = new ModuleAddRequest(); module.ModuleName = name; module.SectionId = sectionId; int newId = _moduleService.InsertModule(module); List <ModuleWikiPages> oldWikiPages = _moduleService.GetModuleWikis(moduleId); Id = newId; if (oldWikiPages != null) { foreach (ModuleWikiPages wikiPage in oldWikiPages) { int wikiPageId = wikiPage.WikiPageId; string userId = UserService.GetCurrentUserId(); WikiPage copyWikiPage = _wikiService.GetWiki(wikiPageId); WikiAddRequest newWikiPage = new WikiAddRequest(); newWikiPage.Title = copyWikiPage.Title; newWikiPage.URL = copyWikiPage.URL; //newWikiPage.Language = copyWikiPage.Language; //newWikiPage.PublishDate = copyWikiPage.PublishDate; int newPageId = _wikiService.Add(newWikiPage, userId); _moduleService.AddWikiPage(Id, newPageId); } } } return(Id); }