コード例 #1
0
        public ActionResult RemoveFriend(int citizenID)
        {
            var currentCitizen = SessionHelper.CurrentEntity.Citizen;

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

            var otherCitizen = citizenRepository.GetById(citizenID);

            if (otherCitizen == null)
            {
                return(RedirectToHomeWithError("Citizen does not exist"));
            }

            MethodResult result;

            if ((result = friendService.CanRemoveFriend(currentCitizen, otherCitizen)).IsError)
            {
                return(RedirectToHomeWithError(result));
            }

            friendService.RemoveFriend(currentCitizen, otherCitizen);
            return(RedirectToAction("View", "Citizen", new { citizenID = citizenID }));
        }