public String SaveAssociatedItems(String model) { ItemProductModel model2Save; Services.ItemProduct itemProduct; Services.ItemProductAssociation itemProductAssociation; try { model2Save = SetModel(model); if (model2Save != null) { foreach (Models.ItemProduct item in model2Save.ItemsProduct) { itemProduct = new Services.ItemProduct(); itemProduct.id = item.id; itemProduct.ItemId = item.ItemId; itemProduct.Type = (Int32)item.Type; foreach (ItemProductAssociation itemAssosiation in item.ItemProductAssociation) { itemProductAssociation = new Services.ItemProductAssociation(); itemProductAssociation.ItemId = itemAssosiation.ItemId; itemProductAssociation.ItemProductId = itemAssosiation.ItemProductId; itemProduct.ItemProductAssociations.Add(itemProductAssociation); } _itemProductService.SaveItemProduct(itemProduct); } } } catch (Exception ex) { base.Log(ex); return ex.Message; } finally { } return "OK"; }
public Boolean SaveItemProduct(ItemProduct item) { ItemProduct itemQuery = new ItemProduct(); try { using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) { if (item.id != 0) { itemQuery = db.ItemProducts.Where(m => m.id == item.id).FirstOrDefault(); } if (itemQuery != default(ItemProduct)) { itemQuery.id = item.id; itemQuery.Type = item.Type; itemQuery.ItemId = item.ItemId; } if (item.id == 0) { db.ItemProducts.InsertOnSubmit(itemQuery); } db.SubmitChanges(); DeleteItemProductAssociations(itemQuery.id); foreach (ItemProductAssociation ipa in item.ItemProductAssociations) { ItemProductAssociation itemsQuery = new ItemProductAssociation(); itemsQuery.ItemProductId = itemQuery.id; itemsQuery.ItemId = ipa.ItemId; db.ItemProductAssociations.InsertOnSubmit(itemsQuery); } db.SubmitChanges(); } } catch (Exception ex) { return false; } return true; }
public String SaveAssociatedItems(String model) { ItemProductModel model2Save; Services.ItemProduct itemProduct; Services.ItemProductAssociation itemProductAssociation; try { model2Save = SetModel(model); if (model2Save != null) { foreach (Models.ItemProduct item in model2Save.ItemsProduct) { itemProduct = new Services.ItemProduct(); itemProduct.id = item.id; itemProduct.ItemId = item.ItemId; itemProduct.Type = (Int32)item.Type; foreach (ItemProductAssociation itemAssosiation in item.ItemProductAssociation) { itemProductAssociation = new Services.ItemProductAssociation(); itemProductAssociation.ItemId = itemAssosiation.ItemId; itemProductAssociation.ItemProductId = itemAssosiation.ItemProductId; itemProduct.ItemProductAssociations.Add(itemProductAssociation); } _itemProductService.SaveItemProduct(itemProduct); } } } catch (Exception ex) { base.Log(ex); return(ex.Message); } finally { } return("OK"); }
public Boolean DeleteItemProduct(Int32? id) { ItemProduct itemProduct = new ItemProduct(); IEnumerable<ItemProductAssociation> itemProductAssocoation; ; id = id.HasValue ? id : 0; try { using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) { itemProductAssocoation = db.ItemProductAssociations.Where(m => m.ItemProductId == id); if (itemProductAssocoation != default(ItemProductAssociation)) { db.ItemProductAssociations.DeleteAllOnSubmit(itemProductAssocoation); } itemProduct = db.ItemProducts.Where(m => m.id == id).FirstOrDefault(); if (itemProduct != default(ItemProduct)) { db.ItemProducts.DeleteOnSubmit(itemProduct); } db.SubmitChanges(); } } catch (Exception ex) { return false; } return true; }
private void detach_ItemProducts(ItemProduct entity) { this.SendPropertyChanging(); entity.Item = null; }
private void attach_ItemProducts(ItemProduct entity) { this.SendPropertyChanging(); entity.Item = this; }
partial void DeleteItemProduct(ItemProduct instance);
partial void UpdateItemProduct(ItemProduct instance);
partial void InsertItemProduct(ItemProduct instance);