public void HandleRequest(IRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var character   = request.Session.Character;
                var corporation = character.GetPrivateCorporationOrThrow();

                var role = corporation.GetMemberRole(character);
                if (role.IsAnyRole(CorporationRole.CEO, CorporationRole.DeputyCEO))
                {
                    throw new PerpetuumException(ErrorCodes.InsufficientPrivileges);
                }

                var volunteerCEO = _volunteerCEOService.GetVolunteer(corporation.Eid);
                if (volunteerCEO != null)
                {
                    _volunteerCEOService.ClearVolunteer(volunteerCEO);
                }
                else
                {
                    corporation.CheckMaxMemberCountAndThrowIfFailed(character);
                    corporation.CheckCeoLastActivityAndThrowIfFailed();
                    role.HasFlag(CorporationRole.CEO).ThrowIfTrue(ErrorCodes.WTFErrorMedicalAttentionSuggested);
                    volunteerCEO = _volunteerCEOService.AddVolunteer(corporation, character);
                }

                Transaction.Current.OnCommited(() => _volunteerCEOService.SendVolunteerStatusToMembers(volunteerCEO));

                scope.Complete();
            }
        }
示例#2
0
        public void HandleRequest(IRequest request)
        {
            var character      = request.Session.Character;
            var corporationEid = character.CorporationEid;

            var volunteerCEO = _volunteerCEOService.GetVolunteer(corporationEid);

            if (volunteerCEO == null)
            {
                Message.Builder.FromRequest(request).WithEmpty().Send();
                return;
            }

            Message.Builder.FromRequest(request).WithData(volunteerCEO.ToDictionary()).Send();
        }