Example #1
0
        public string EditImage(int id, IFormFile image)
        {
            var picture = procuctDb.Pictures.Find(id);

            if (picture != null)
            {
                var file = picture.PhotoUrl;
                picture.PhotoUrl = image.CreateImage(hostEnvironment);
                if (file != picture.PhotoUrl)
                {
                    ImageExtension.DeleteImage(file, hostEnvironment);
                }
                procuctDb.SaveChanges();
                return(picture.PhotoUrl);
            }
            return(null);
        }