Example #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;

            }
        }
Example #2
0
 partial void Deletetexts_value(texts_value instance);
Example #3
0
 partial void Updatetexts_value(texts_value instance);
Example #4
0
 partial void Inserttexts_value(texts_value instance);
Example #5
0
		private void detach_texts_values(texts_value entity)
		{
			this.SendPropertyChanging();
			entity.text = null;
		}
Example #6
0
		private void attach_texts_values(texts_value entity)
		{
			this.SendPropertyChanging();
			entity.text = this;
		}
Example #7
0
        public object add(InputModels.ProductInputModel p)
        {
            using (LangDataContext dc = new LangDataContext())
            {
                product prod = new product();
                prod.text_title = new text();
                prod.text_subtitle = new text();
                prod.text_description = new text();
                prod.text_text = new text();

                foreach (InputModels.ProductInputModel.Product inProd in p.request)
                {
                    texts_value titleval = new texts_value();
                    titleval.culture = inProd.lang;
                    titleval.value = inProd.data.Title;
                    titleval.text = prod.text_title;
                    titleval.seo_value = this._app.makeAlias(inProd.data.Title);

                    texts_value subtitleval = new texts_value();
                    subtitleval.culture = inProd.lang;
                    subtitleval.value = inProd.data.Subtitle;
                    subtitleval.text = prod.text_subtitle;

                    texts_value descval = new texts_value();
                    descval.culture = inProd.lang;
                    descval.value = inProd.data.Shortdesc;
                    descval.text = prod.text_description;

                    texts_value textval = new texts_value();
                    textval.culture = inProd.lang;
                    textval.value = inProd.data.Content;
                    textval.text = prod.text_text;
                }

                if (p.docGroups != null)
                {
                    foreach (InputModels.DocGroupInputModel dg in p.docGroups)
                    {
                        if (dg.Id == null) continue;

                        docgroups_product dgp = new docgroups_product();
                        dgp.docgroup_id = (long)dg.Id;
                        dgp.product = prod;
                    }
                }

                foreach (long cat in p.Categories)
                {
                    products_category pc = new products_category();
                    pc.product = prod;
                    pc.category_id = cat;
                }

                foreach (long conn in p.Connections)
                {
                    products_connection prodConn = new products_connection();
                    prodConn.product = prod;
                    prodConn.product_id_2 = conn;
                }

                prod.image_id = p.mainImage;

                dc.products.InsertOnSubmit(prod);

                dc.SubmitChanges();

                return new { Id = prod.id };
            }
        }
Example #8
0
        public long add(CategoryInputModel input)
        {
            using (LangDataContext dataContext = new LangDataContext())
            {
                category c = new category();

                text title = new text();
                text content = new text();

                dataContext.categories.InsertOnSubmit(c);
                dataContext.texts.InsertOnSubmit(title);
                dataContext.texts.InsertOnSubmit(content);

                c.text = content;
                c.title = title;

                foreach (CategoryInputModel.Category cat in input.request)
                {
                    texts_value titleValue = new texts_value();
                    titleValue.culture = cat.lang;
                    titleValue.value = cat.data.Title;
                    titleValue.text = title;
                    titleValue.seo_value = this._app.makeAlias(cat.data.Title);

                    texts_value contentValue = new texts_value();
                    contentValue.culture = cat.lang;
                    contentValue.value = cat.data.Content;
                    contentValue.text = content;

                    dataContext.texts_values.InsertOnSubmit(titleValue);
                    dataContext.texts_values.InsertOnSubmit(contentValue);
                }

                c.parentid = input.catParent;
                c.date = DateTime.Now;

                dataContext.SubmitChanges();

                return c.id;

            }
        }
Example #9
0
        public bool edit(CategoryInputModel input)
        {
            using (LangDataContext dc = new LangDataContext())
            {
                category c = dc.categories.Single(x => x.id == input.catId);

                foreach (String lang in Helpers.LangHelper.langs)
                {
                    texts_value titleval = c.title.texts_values.SingleOrDefault(x => x.culture == lang);
                    string value = input.request.Single(x => x.lang == lang).data.Title;

                    if (titleval == null)
                    {
                        titleval = new texts_value();
                        titleval.text = c.title;
                        titleval.culture = lang;
                    }

                    titleval.value = value;
                    titleval.seo_value = this._app.makeAlias(value);

                    texts_value text = c.text.texts_values.SingleOrDefault(x => x.culture == lang);
                    if (text == null)
                    {
                        text = new texts_value();
                        text.text = c.text;
                        text.culture = lang;
                    }

                    text.value = input.request.Single(x => x.lang == lang).data.Content;
                }

                dc.SubmitChanges();
            }

            return true;
        }
Example #10
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;
        }