public async Task <IActionResult> UpdateDadInfo(string Id, UpdateDadInfoRequest request)
        {
            if (Id != request.Id)
            {
                return(BadRequest());
            }

            return(Ok(await _dadInfoService.UpdateDadInfoRequest(request)));
        }
示例#2
0
        public async Task <Response <string> > UpdateDadInfoRequest(UpdateDadInfoRequest request)
        {
            var dadInfo = await _unitOfWork.DadInfoRepository.FirstAsync(x => x.Id == request.Id);

            if (dadInfo == null)
            {
                return(new Response <string>(null, $"Không tìm thấy thông tin ba \'{request.Id}\'."));
            }

            dadInfo.FullName     = request.FullName;
            dadInfo.ImageUrl     = request.ImageURL;
            dadInfo.Birthday     = request.Birthday;
            dadInfo.Phonenumber  = request.Phonenumber;
            dadInfo.BloodGroup   = request.BloodGroup;
            dadInfo.RhBloodGroup = request.RhBloodGroup;

            _unitOfWork.DadInfoRepository.UpdateAsync(dadInfo);
            await _unitOfWork.SaveAsync();

            return(new Response <string>(dadInfo.Id, $"Cập nhật thông tin ba thành công, id: {dadInfo.Id}"));
        }