Ejemplo n.º 1
0
        public void DeleteAdvertImage(int advertImageId)
        {
            AdvertImage advertImage = AdvertImages.FirstOrDefault(a => a.AdvertImageId == advertImageId);

            if (advertImage != null)
            {
                context.Remove(advertImage);
                context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public void UploadAdvertImages(List <IFormFile> files, int advertId)
        {
            foreach (IFormFile file in files)
            {
                imageService.UploadImage(file);
                AdvertImage advertImage = new AdvertImage()
                {
                    ImagePath = file.FileName,
                    AdvertId  = advertId
                };

                context.AdvertImages.Add(advertImage);
            }

            context.SaveChanges();
        }