예제 #1
0
        public ActionResult CancelFriendRequest(int requestID)
        {
            var request = friendRepository.GetFriendRequest(requestID);

            if (request == null)
            {
                return(RedirectToHomeWithError("Request does not exist!"));
            }

            var currentCitizen = SessionHelper.CurrentEntity.Citizen;

            if (currentCitizen == null)
            {
                return(RedirectToHomeWithError("You must be an citizen to make friends."));
            }

            MethodResult result;

            if ((result = friendService.CanRemoveRequest(currentCitizen, request)).IsError)
            {
                return(RedirectToHomeWithError(result));
            }

            friendService.RemoveRequest(request);

            return(RedirectToAction("View", "Citizen", new { citizenID = request.SecondCitizenID }));
        }