コード例 #1
0
ファイル: MemberModule.cs プロジェクト: half-ogre/rpg-rooms
        static object DeleteMember(
            NancyContext context,
            IDocumentSession documentSession,
            string alias)
        {
            if (context == null) throw new ArgumentNullException("context");
            if (documentSession == null) throw new ArgumentNullException("documentSession");

            if (String.IsNullOrEmpty(alias))
                return 404;

            if (!context.IsSignedUp())
                return 403;

            var memberToDelete = documentSession.GetMemberByAlias(alias);
            if (memberToDelete == null)
                return 404;

            var currentMember = context.GetCurrentMember(documentSession);
            Debug.Assert(currentMember != null, "`requireSignedUp()` should ensure the current member is not null.");

            if (!memberToDelete.Alias.Equals(currentMember.Alias, StringComparison.OrdinalIgnoreCase))
                return 403;

            documentSession.DeleteMember(memberToDelete.Id);

            context.SetAlert("Your membership was deleted.", type: AlertType.Success);

            context.SignOutOfTwitter();

            return context.Redirect(Paths.Home());
        }
コード例 #2
0
ファイル: SessionModule.cs プロジェクト: half-ogre/rpg-rooms
        static object DeleteSession(NancyContext context)
        {
            context.Ensure("context");

            context.SetAlert("You successfully signed out.", type: AlertType.Success);

            context.SignOutOfTwitter();

            return context.Redirect(Paths.Home());
        }