Example #1
0
        public async Task <IActionResult> GiveReviewForUser([FromBody] GiveReviewForUserRequest giveReviewForUserRequest)
        {
            try
            {
                var id   = HttpContext.User.FindFirst(ClaimTypes.Email).Value;
                var user = await _userManager.FindByEmailAsync(id);

                var reviewUser = await _userManager.FindByIdAsync(giveReviewForUserRequest.OwnerId);

                if (user == null)
                {
                    return(StatusCode((int)HttpStatusCode.BadRequest, "Wrong User"));
                }

                if (reviewUser == null)
                {
                    return(StatusCode((int)HttpStatusCode.BadRequest, "User does not exist"));
                }

                await _userCommand.GiveUserReviewCommand(giveReviewForUserRequest, user.Id, _userManager);

                return(Ok(new
                {
                    Success = true,
                    Message = "Success fully added review."
                }));
            }
            catch (Exception e)
            {
                _logger.LogError($"error while changing profile for user: {e}");
                return(StatusCode((int)HttpStatusCode.InternalServerError, "error while changing profile for user"));
            }
        }