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";
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
        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");
        }
Ejemplo n.º 4
0
        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;
        }
Ejemplo n.º 5
0
		private void detach_ItemProducts(ItemProduct entity)
		{
			this.SendPropertyChanging();
			entity.Item = null;
		}
Ejemplo n.º 6
0
		private void attach_ItemProducts(ItemProduct entity)
		{
			this.SendPropertyChanging();
			entity.Item = this;
		}
Ejemplo n.º 7
0
 partial void DeleteItemProduct(ItemProduct instance);
Ejemplo n.º 8
0
 partial void UpdateItemProduct(ItemProduct instance);
Ejemplo n.º 9
0
 partial void InsertItemProduct(ItemProduct instance);