Example #1
0
        public IHttpActionResult AcceptFriend(int id, [FromBody] FriendRequestDTO friendRequest)
        {
            var request = _requestService.GetById(id);

            if (request == null)
            {
                return(NotFound());
            }
            var userId = RequestContext.Principal.Identity.GetUserId();

            if (userId != request.RequestedTo.Id)
            {
                return(StatusCode(HttpStatusCode.Forbidden));
            }

            _requestService.AcceptFriend(request);
            return(Ok());
        }