示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="user"></param>
        public void Update(AuthorPutViewModel user)
        {
            var entity = _context.Authors.FirstOrDefault(f => f.Id == user.Id);

            entity.AuthorName = user.AuthorName;

            _context.Update(entity);

            _context.SaveChanges();
        }
        public void Update(BookPutViewModel user)
        {
            var book = _context.Books.FirstOrDefault(f => f.Id == user.Id);

            book.Name     = user.Name;
            book.AuthorId = user.AuthorId;
            book.BookUrl  = BookUrl == null ? book.BookUrl : BookUrl;
            book.PhotoUrl = PhotoUrl == null ? user.PhotoUrl : PhotoUrl;

            _context.Update(book);
            _context.SaveChanges();

            BookUrl  = null;
            PhotoUrl = null;
        }