Ejemplo n.º 1
0
        public ActionResult SendFriendRequest(int citizenID)
        {
            var citizen = citizenRepository.GetById(citizenID);

            if (citizen == null)
            {
                return(RedirectToHomeWithError("Citizen with this ID 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.CanSendFriendRequest(currentCitizen, citizen)).IsError)
            {
                return(RedirectBackWithError(result));
            }

            friendService.SendFriendRequest(currentCitizen, citizen);

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