public async Task <IActionResult> UpdateMomInfo(string Id, UpdateMomInfoRequest request) { if (Id != request.Id) { return(BadRequest()); } return(Ok(await _momInfoService.UpdateMomInfoRequest(request))); }
public async Task <Response <string> > UpdateMomInfoRequest(UpdateMomInfoRequest request) { var user = await _unitOfWork.UserRepository.FirstAsync(x => x.Id == request.Id && x.DelFlag == false, includeProperties : "MomInfo,UserInfo"); if (user == null) { return(new Response <string>(null, $"Không tìm thấy thông tin tài khoản \'{request.Id}\'.")); } user.UserInfo.FullName = request.FullName; user.UserInfo.ImageUrl = request.ImageUrl; user.UserInfo.Birthday = request.BirthDay; user.UserInfo.Phonenumber = request.Phonenumber; user.MomInfo.BloodGroup = request.BloodGroup; user.MomInfo.RhBloodGroup = request.RhBloodGroup; _unitOfWork.UserRepository.UpdateAsync(user); await _unitOfWork.SaveAsync(); return(new Response <string>(user.Id, $"Cập nhật thông tin thành công, {user.Id}")); }