Exemplo n.º 1
0
        public async Task <BookListModel> Edit(BookListModel bookList)
        {
            BookListModel item = await GetRaw(bookList.Id);

            if (item == null)
            {
                return(null);
            }

            if (!item.Removable)
            {
                return(item);
            }

            item.Color = bookList.Color;
            item.Name  = bookList.Name;
            _context.Entry(item).State = EntityState.Modified;

            try
            {
                _context.Update(item);
                await _context.SaveChangesAsync();

                return(bookList);
            }
            catch (DbUpdateConcurrencyException)
            {
                return(item);
            }
        }
        public async Task <bool> UpdateBook(Book book)
        {
            _context.Entry(book).State = EntityState.Modified;

            return(await _context.SaveChangesAsync() > 0);
        }