Example #1
0
 public void Delete(string name)
 {
     using (WGHotelsEntities db = new WGHotelsEntities())
     {
         var ImageFile = db.ImageStore.Where(o => o.Name == name).FirstOrDefault();
         if (ImageFile != null)
         {
             db.ImageStore.Attach(ImageFile);
             db.ImageStore.Remove(ImageFile);
             db.SaveChanges();
         }
     }
 }
Example #2
0
 public void Save(List <ImageViewModel> models)
 {
     using (WGHotelsEntities db = new WGHotelsEntities())
     {
         var dbImg = db.ImageStore;
         var Now   = DateTime.Now;
         foreach (var img in models)
         {
             dbImg.Add(new ImageStore {
                 ReferIdUS = img.ReferIdUS,
                 ReferIdZH = img.ReferIdZH,
                 Created   = Now, Image = img.Image,
                 Extension = img.Extension,
                 Deleted   = false,
                 Path      = null,
                 Name      = img.Name,
                 Type      = img.Type
             });
         }
         db.SaveChanges();
     }
 }