public virtual void Update(T entity)
 {
     _db.Entry(entity).State = EntityState.Modified;
     _db.Entry(entity).Property(x => x.CreatedBy).IsModified = false;
     _db.Entry(entity).Property(x => x.CreatedOn).IsModified = false;
     _db.SaveChanges();
 }
Example #2
0
        public IActionResult AddNewImage(int id, IFormFile ImagePath)
        {
            var art = new Art();

            Console.WriteLine(ImagePath);
            art.ImagePath = ImagePath.FileName;
            art.AlbumId   = id;

            string path = "/images/" + ImagePath.FileName;

            using (var fileStream = new FileStream(_appEnvironment.WebRootPath + path, FileMode.Create))
            {
                ImagePath.CopyTo(fileStream);
            }

            _context.Art.Add(art);
            _context.SaveChanges();
            return(Content("You have create new album: " + ImagePath.FileName));
        }