Ejemplo n.º 1
0
        public IActionResult CreateFollow([FromBody] FollowRequestData RequestData)
        {
            if (!_service.IsAuthorizedRider(RequestData))
            {
                return(Unauthorized());
            }

            if (!_service.RiderExists(RequestData.FollowerId))
            {
                return(NotFound());
            }
            if (!_service.RiderExists(RequestData.FollowingId))
            {
                return(NotFound());
            }

            if (_service.FollowExists(RequestData))
            {
                return(Ok(_service.GetFollow(RequestData)));
            }

            if (ModelState.IsValid)
            {
                var follow = _service.AddFollow(RequestData);
                return(Ok(follow));
            }
            return(Unauthorized());
        }
Ejemplo n.º 2
0
        public ApiResult CheckIfFollows(string id)
        {
            try
            {
                var followerId = User.Claims.First(c => c.Type == ClaimTypes.Name).Value.ToString();

                var result = _followService.FollowExists(followerId, id);

                return(ApiResult.Success(result));
            }
            catch (System.Exception)
            {
                return(ApiResult.BadRequest("Something went wrong"));
            }
        }