public GalleryVM(GalleryDBO row) { Id = row.Id; ProductId = row.ProductId; Img = row.Img; ImgType = row.ImgType; }
public void DeleteImg(int id) { GalleryDBO dto = db.ProductGallery.Find(id); db.ProductGallery.Remove(dto); db.SaveChanges(); }
public FileContentResult GetGallery(int id) { GalleryDBO img = db.ProductGallery.Find(id); if (img != null) { return(File(img.Img, img.ImgType)); } else { return(null); } }
public void SaveGallaryImages(int id, IFormFile file) //не работает при создании товара т.к. у товора до создания нету ИД { if (file != null && file.Length > 0) { GalleryDBO dto = new GalleryDBO(); byte[] imageData = null; using (var br = new BinaryReader(file.OpenReadStream())) { imageData = br.ReadBytes((int)file.Length); } dto.ProductId = id; dto.Img = imageData; dto.ImgType = file.ContentType; db.ProductGallery.Add(dto); db.SaveChanges(); } }