Esempio n. 1
0
        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;

            }
        }
Esempio n. 2
0
 public ActionResult AddPageAjax(PageInputModel p)
 {
     return Json(this._app.pages().add(p));
 }
Esempio n. 3
0
 public ActionResult EditPageAjax(PageInputModel p)
 {
     return Json(this._app.pages().edit(p));
 }
Esempio n. 4
0
 public ActionResult EditNewsAjax(PageInputModel p)
 {
     return Json(this._app.news().edit(p));
 }
Esempio n. 5
0
        public bool edit(PageInputModel input)
        {
            using (LangDataContext dC = new LangDataContext())
            {
                page p = dC.pages.Where(x => x.id == input.request[0].Id).Single();

                foreach (string lang in Helpers.LangHelper.langs)
                {
                    var titleTxt = p.text.texts_values.SingleOrDefault(x => x.culture == lang);
                    var txtTxt = p.text1.texts_values.SingleOrDefault(x => x.culture == lang);

                    if (titleTxt == null)
                    {
                        titleTxt = new texts_value();
                        titleTxt.culture = lang;
                        titleTxt.text = p.text;
                    }

                    if (txtTxt == null)
                    {
                        txtTxt = new texts_value();
                        txtTxt.culture = lang;
                        txtTxt.text = p.text1;
                    }

                    titleTxt.value = input.request.Single(x => x.lang == lang).data.title;
                    titleTxt.seo_value = this._app.makeAlias(input.request.Single(x => x.lang == lang).data.title);

                    txtTxt.value = input.request.Single(x => x.lang == lang).data.content;
                }

                dC.SubmitChanges();
            }

            return true;
        }