public int Add(WikiAddRequest model, string userId) { int Id = 0; DataProvider.ExecuteNonQuery(GetConnection, "dbo.WikiPages_Insert" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@UserId", userId); paramCollection.AddWithValue("@Name", model.Title); paramCollection.AddWithValue("@URL", model.URL); paramCollection.AddWithValue("@PublishDate", null); paramCollection.AddWithValue("@Language", null); // model.Language); paramCollection.AddWithValue("@LastModifiedByUserId", userId); SqlParameter p = new SqlParameter("@Id", System.Data.SqlDbType.Int); p.Direction = System.Data.ParameterDirection.Output; paramCollection.Add(p); }, returnParameters : delegate(SqlParameterCollection param) { int.TryParse(param["@Id"].Value.ToString(), out Id); } ); //foreach (var wikiSpaceId in model.WikiSpaceIds) // DataProvider.ExecuteNonQuery(GetConnection, "dbo.WikiPageSpaces_Insert" // , inputParamMapper: delegate (SqlParameterCollection param) // { // param.AddWithValue("@WikiPageId", Id); // param.AddWithValue("@WikiSpaceId", wikiSpaceId); // }); return(Id); }
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); }