Ejemplo n.º 1
0
        public async Task <IActionResult> PutAuthor(AuthorPostModel authorPostModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new { error_message = "Loi cu phap" }));
            }
            Author author = await _authorServices.FindAuthorAsync(authorPostModel.Id);

            if (author is null)
            {
                return(Ok(new { error_message = "Khong tim thay tac gia" }));
            }
            bool IsUpdateAuthor = await _authorServices.UpdateAuthorAsync(author, authorPostModel);

            if (IsUpdateAuthor)
            {
                return(Ok(new { data = author, success = true }));
            }
            else
            {
                return(Ok(new { error_message = "Khong co gi thay doi" }));
            }
        }