public async Task <IActionResult> UpdateProfileBaseInfo([FromBody] UpdateProfileBaseInfoCommand model) { FirebaseUser user = HttpContext.GetFirebaseUser(); model.firebaseId = user.UserId; ResultWrapper <UpdateProfileBaseInfoOutput> result = new ResultWrapper <UpdateProfileBaseInfoOutput>(); result = await _mediator.Send(model); return(Ok(result)); }
public async Task <ResultWrapper <UpdateProfileBaseInfoOutput> > Handle(UpdateProfileBaseInfoCommand request, CancellationToken cancellationToken) { ResultWrapper <UpdateProfileBaseInfoOutput> updateProfileResult = new ResultWrapper <UpdateProfileBaseInfoOutput>(); TUser tUser = _dbContext.TUser.FirstOrDefault(x => x.FireBaseId == request.firebaseId); if (tUser == null) { updateProfileResult.Status = false; updateProfileResult.Message = "User doesn't exists"; return(updateProfileResult); } tUser.FirstName = request.FirstName; tUser.LastName = request.LastName; tUser.BirthYear = request.BirthYear; tUser.Phone = request.Phone; tUser.PostalCode = request.PostalCode; tUser.Address = request.Address; tUser.TRegionCityId = request.CityId; _dbContext.TUser.Update(tUser); int r = await _dbContext.SaveChangesAsync(); if (r <= 0) { updateProfileResult.Status = false; updateProfileResult.Message = "Unhandled error!"; return(updateProfileResult); } updateProfileResult.Status = true; updateProfileResult.Result = new UpdateProfileBaseInfoOutput() { }; return(updateProfileResult); }