Esempio n. 1
0
        public static void ToUpdateEntity(this AuthorUpdateRequest request, ref AuthorEntity author)
        {
            if (request == null || author == null)
            {
                return;
            }

            if (!string.IsNullOrEmpty(request.FirstName))
            {
                author.FirstName = request.FirstName;
            }

            if (!string.IsNullOrEmpty(request.LastName))
            {
                author.LastName = request.LastName;
            }

            if (!string.IsNullOrEmpty(request.LastName))
            {
                author.MainCategory = request.MainCategory;
            }

            if (!string.IsNullOrEmpty(request.LastName))
            {
                author.DateOfBirth = request.DateOfBirth;
            }
        }
Esempio n. 2
0
        public async Task Update(AuthorUpdateRequest dto)
        {
            var data = await this._authorRepo.GetAsync(dto.Id);

            data.Name        = dto.Name;
            data.Description = dto.Description;

            var result = await this._authorRepo.UpdateAsync(data);
        }
Esempio n. 3
0
        public async Task <ActionResult <AuthorDto> > UpdateAuthor(Guid authorId, [FromBody] AuthorUpdateRequest authorRequest)
        {
            AuthorDto author = await _authorService.UpdateAuthorAsync(authorId, authorRequest);

            if (author == null)
            {
                return(NotFound());
            }

            return(Ok(author));
        }
Esempio n. 4
0
        public AuthorResponse UpdateAuthor(int authorId, AuthorUpdateRequest author)
        {
            var authorToUpdate = _mapper.Map <Author>(author);

            authorToUpdate.AuthorId = authorId;

            var updatedAuthor = _libraryContext.Authors.Update(authorToUpdate);

            _libraryContext.SaveChanges();
            return(_mapper.Map <AuthorResponse>(updatedAuthor.Entity));;
        }
Esempio n. 5
0
        public async Task <IActionResult> Put(int id, [FromBody] AuthorUpdateRequest model)
        {
            var data = await this._authorService.GetById(id);

            if (data == null)
            {
                return(BadRequest(new { error = "Data is not exist" }));
            }

            await this._authorService.Update(model);

            var result = new ApiResult <AuthorDetailResponse>()
            {
                Message = "update success",
                Data    = null
            };

            return(Ok(result));
        }
Esempio n. 6
0
        public async Task <AuthorDto> UpdateAuthorAsync(Guid authorId, AuthorUpdateRequest authorRequest)

        {
            if (authorId == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(authorId));
            }

            AuthorEntity author = await _context.Authors.FirstOrDefaultAsync(x => x.Id == authorId);

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

            authorRequest.ToUpdateEntity(ref author);

            await _context.SaveChangesAsync();

            return(author.ToDto());
        }
Esempio n. 7
0
        } // AuthorSelect

        public static void AuthorUpdate(AuthorUpdateRequest payload)
        {
            AuthorUpdate(payload.ID, payload.Email);
        } //AuthorUpdate