Пример #1
0
        public JsonResult InviteAjax(int partyID, int citizenID)
        {
            var currentCitizen = SessionHelper.CurrentEntity;

            if (currentCitizen.GetEntityType() != EntityTypeEnum.Citizen)
            {
                return(JsonError("You are not a citizen!"));
            }

            var          party   = partyRepository.GetById(partyID);
            var          citizen = citizenRepository.GetById(citizenID);
            MethodResult result;

            if ((result = partyService.CanInviteCitizen(SessionHelper.LoggedCitizen, party, citizen)).IsError)
            {
                return(JsonError(result));
            }

            partyService.InviteCitizen(citizen, party);
            return(JsonSuccess($"You invited {citizen.Entity.Name} to {party.Entity.Name}"));
        }