コード例 #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());
        }