예제 #1
0
 public object GetLastImageId()
 {
     using (var db = new StoreDataBaseDataContext())
     {
         return((db.GoodImages?.Max(s => s.id) + 1) ?? 1);
     }
 }
예제 #2
0
 public void ImageGoodDelete(long imageId)
 {
     using (var db = new StoreDataBaseDataContext())
     {
         var image = db.GoodImages.First(s => s.id == imageId);
         db.GoodImages.DeleteOnSubmit(image);
         db.SubmitChanges();
     }
 }
예제 #3
0
 public void SetPrimaryImage(long imageId)
 {
     using (var db = new StoreDataBaseDataContext())
     {
         var image           = db.GoodImages.First(s => s.id == imageId);
         var imageOldPrimary = db.GoodImages.FirstOrDefault(s => s.goodId == image.goodId && s.isPrimary == true);
         if (imageOldPrimary != null)
         {
             imageOldPrimary.isPrimary = false;
         }
         image.isPrimary = true;
         db.SubmitChanges();
     }
 }
예제 #4
0
 public void AddGoodImage(long goodId, string imageName)
 {
     using (var db = new StoreDataBaseDataContext())
     {
         var isPrimary = db.GoodImages.Count(s => s.goodId == goodId) == 0;
         var goodImage = new GoodImages
         {
             goodId    = goodId,
             imageUrl  = imageName,
             isPrimary = isPrimary
         };
         db.GoodImages.InsertOnSubmit(goodImage);
         db.SubmitChanges();
     }
 }