示例#1
0
        public async Task Remove(BooksServ book)
        {
            book.SoftDeleted = true;

            _context.Entry(_mapper.Map <Books>(book)).State = EntityState.Modified;

            await _context.SaveChangesAsync();
        }
示例#2
0
        public async Task <IActionResult> PutReview([FromRoute] Guid id, [FromBody] Review review)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != review.ReviewId)
            {
                return(BadRequest());
            }

            _context.Entry(review).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ReviewExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutBookAuthor([FromRoute] Guid id, [FromBody] BookAuthor bookAuthor)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != bookAuthor.BooksId)
            {
                return(BadRequest());
            }

            _context.Entry(bookAuthor).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BookAuthorExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#4
0
        public async Task Update(AuthorServ author)
        {
            var validator = _validator.Validate(author);

            validator.ThrowIfInvalid();

            _context.Entry(_mapper.Map <Author>(author)).State = EntityState.Modified;

            await _context.SaveChangesAsync();
        }