예제 #1
0
파일: Properties.cs 프로젝트: adizka/iShop
        public bool UpdateAllPropertiesByCategoryId(IQueryable<BL.CategoryProperty> properties, Guid categoryId)
        {
            bool updateProperties = false;

            using (ShopDataContext db = new ShopDataContext())
            {
                BL.Category category = db.Categories.Where(c => c.CategoryID == categoryId).FirstOrDefault();
                if (category != null)
                {
                    using (var ts = new TransactionScope())
                    {
                        db.CategoryProperties.AttachAll(properties);
                        db.Refresh(System.Data.Linq.RefreshMode.KeepCurrentValues, properties);
                        db.SubmitChanges();
                        ts.Complete();
                        updateProperties = true;
                    }
                }
            }
            return updateProperties;
        }
예제 #2
0
파일: Categories.cs 프로젝트: adizka/iShop
 public void UpdateCategoryName(Guid categoryId, string name)
 {
     using (var db = new ShopDataContext())
     {
         BL.Category category = db.Categories.Where(c => c.CategoryID == categoryId).FirstOrDefault();
         if (category != null)
         {
             category.Name = name;
             db.SubmitChanges();
         }
         db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues);
     }
 }
예제 #3
0
파일: Categories.cs 프로젝트: adizka/iShop
        public void UpdateCategory(Guid categoryId, string name, Guid? parentId)
        {
            using (ShopDataContext db = new ShopDataContext())
            {
                BL.Category category = db.Categories.Where(c => c.CategoryID == categoryId).FirstOrDefault();
                if (category != null)
                {
                    using (var ts = new TransactionScope())
                    {
                        category.Name = name;
                        category.ParentID = parentId;
                        db.SubmitChanges();
                        ts.Complete();
                        db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues);
                    }
                }

            }
        }
예제 #4
0
파일: Categories.cs 프로젝트: adizka/iShop
        public void UpdateAllCategories(List<Guid> categories)
        {
            using (var db = new ShopDataContext())
            {

                using (var ts = new TransactionScope())
                {
                    var index = 0;
                    foreach (var item in categories)
                    {
                        var categ = db.Categories.First(c => c.CategoryID == item);
                        categ.Sort = index;
                        index++;
                    }
                    db.SubmitChanges();
                    db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues);
                    ts.Complete();
                }
            }
        }
예제 #5
0
 public bool UpdateProductPhotoProperty(string url, Guid propId)
 {
     bool allRight = false;
     using (ShopDataContext db = new ShopDataContext())
     {
         BL.ProductProperty productProperty = db.ProductProperties.Where(p => p.PropertyID == propId).FirstOrDefault();
         if (productProperty != null)
         {
             productProperty.PropertyValue = url;
             db.SubmitChanges();
             db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, db.ProductProperties);
             allRight = true;
         }
     }
     return allRight;
 }