Exemplo n.º 1
0
        public async Task <IActionResult> UpdateProfileBodyInfo([FromBody] UpdateProfileBodyInfoCommand model)
        {
            FirebaseUser user = HttpContext.GetFirebaseUser();

            model.firebaseId = user.UserId;
            ResultWrapper <UpdateProfileBodyInfoOutput> result = new ResultWrapper <UpdateProfileBodyInfoOutput>();

            result = await _mediator.Send(model);

            return(Ok(result));
        }
        public async Task <ResultWrapper <UpdateProfileBodyInfoOutput> > Handle(UpdateProfileBodyInfoCommand request, CancellationToken cancellationToken)
        {
            ResultWrapper <UpdateProfileBodyInfoOutput> updateProfileResult = new ResultWrapper <UpdateProfileBodyInfoOutput>();


            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.Weight      = request.Weight;
            tUser.Height      = request.Height;
            tUser.Waist       = request.Waist;
            tUser.Hips        = request.Hips;
            tUser.Forearms    = request.Forearms;
            tUser.Fat         = request.Fat;
            tUser.TBodyTypeId = request.BodyTypeId;
            _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 UpdateProfileBodyInfoOutput()
            {
            };

            return(updateProfileResult);
        }