public ProductOutputModel(product p) { Id = p.id; Title = new LangOutputModel(p.text_title); //SEO Subtitle = new LangOutputModel(p.text_subtitle); Shortdesc = new LangOutputModel(p.text_description); Content = new LangOutputModel(p.text_text); ConnectedProducts = new List<ProductOutputModel>(); foreach (product conn in p.products_connections.Select(x => (x.product == p) ? x.product1 : x.product)) { ConnectedProducts.Add(new ProductOutputModel(conn)); } Categories = p.products_categories.Select(x => new CategoryOutputModel(x.category)).ToList<CategoryOutputModel>(); if (p.image != null) { mainImage = new ImageOutputModel(p.image); } documents = new List<DocumentGroupOutputModel>(); foreach (docgroup dg in p.docgroups_products.Select(x => x.docgroup)) { documents.Add(new DocumentGroupOutputModel(dg)); } }
partial void Deleteproduct(product instance);
partial void Updateproduct(product instance);
partial void Insertproduct(product instance);
private void detach_products(product entity) { this.SendPropertyChanging(); entity.image = null; }
private void attach_products(product entity) { this.SendPropertyChanging(); entity.image = this; }
private void detach_products3(product entity) { this.SendPropertyChanging(); entity.text_title = null; }
private void attach_products2(product entity) { this.SendPropertyChanging(); entity.text_text = this; }
private void attach_products1(product entity) { this.SendPropertyChanging(); entity.text_subtitle = this; }
private void detach_products(product entity) { this.SendPropertyChanging(); entity.text_description = null; }
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 }; } }