public long add(PageInputModel input) { using (LangDataContext dataContext = new LangDataContext()) { page p = new page(); text title = new text(); text content = new text(); dataContext.pages.InsertOnSubmit(p); dataContext.texts.InsertOnSubmit(title); dataContext.texts.InsertOnSubmit(content); p.text = title; p.text1 = content; foreach (PageInputModel.Page newPage in input.request) { texts_value titleValue = new texts_value(); titleValue.culture = newPage.lang; titleValue.value = newPage.data.title; titleValue.text = title; titleValue.seo_value = this._app.makeAlias(newPage.data.title); texts_value contentValue = new texts_value(); contentValue.culture = newPage.lang; contentValue.value = newPage.data.content; contentValue.text = content; dataContext.texts_values.InsertOnSubmit(titleValue); dataContext.texts_values.InsertOnSubmit(contentValue); } dataContext.SubmitChanges(); return p.id; } }
partial void Deletepage(page instance);
partial void Updatepage(page instance);
partial void Insertpage(page instance);
private void detach_pages1(page entity) { this.SendPropertyChanging(); entity.text1 = null; }
private void attach_pages1(page entity) { this.SendPropertyChanging(); entity.text1 = this; }
private PageListOutputModel getPOM(page p) { PageListOutputModel pom = new PageListOutputModel(); pom.Id = p.id; LangOutputModel title = new LangOutputModel(); LangOutputModel content = new LangOutputModel(); foreach (string lang in Helpers.LangHelper.langs) { title.setByCulture(lang, p.text.texts_values.Single(x => x.culture == lang).value); content.setByCulture(lang, p.text1.texts_values.Single(x => x.culture == lang).value); } pom.Title = title; pom.Content = content; return pom; }