当前位置: 首页>>代码示例>>C#>>正文


C# NancyContext.IsSignedUp方法代码示例

本文整理汇总了C#中Nancy.NancyContext.IsSignedUp方法的典型用法代码示例。如果您正苦于以下问题:C# NancyContext.IsSignedUp方法的具体用法?C# NancyContext.IsSignedUp怎么用?C# NancyContext.IsSignedUp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nancy.NancyContext的用法示例。


在下文中一共展示了NancyContext.IsSignedUp方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DeleteMember

        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());
        }
开发者ID:half-ogre,项目名称:rpg-rooms,代码行数:32,代码来源:MemberModule.cs

示例2: GetMember

        static object GetMember(
            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 member = documentSession.GetMemberByAlias(alias);
            if (member == null)
                return 404;

            var currentMember = context.GetCurrentMember(documentSession);
            Debug.Assert(currentMember != null, "`requireSignedUp()` should ensure the current member is not null.");
            if (!member.Alias.Equals(currentMember.Alias, StringComparison.OrdinalIgnoreCase))
                return 403;

            var rooms = documentSession.GetRoomsByOwner(member.Id);

            return new MemberResponse(member, rooms);
        }
开发者ID:half-ogre,项目名称:rpg-rooms,代码行数:27,代码来源:MemberModule.cs

示例3: GetRoom

        static object GetRoom(
            NancyContext context,
            IDocumentSession documentSession,
            string slug)
        {
            context.Ensure("context");
            documentSession.Ensure("documentSession");

            if (string.IsNullOrEmpty(slug))
                return 404;

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

            var room = documentSession.GetRoomBySlug(slug);
            if (room == null)
                return 404;

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

            var posts = documentSession.GetPostsByRoom(room.Id).ToArray();

            return new RoomResponse(currentMember, room, posts);
        }
开发者ID:half-ogre,项目名称:rpg-rooms,代码行数:25,代码来源:RoomModule.cs

示例4: GetHome

        static object GetHome(NancyContext context, IDocumentSession documentSession)
        {
            if (context == null) throw new ArgumentNullException("context");

            var alert = context.GetAlert();

            if (context.IsSignedUp())
            {
                var currentMember = context.GetCurrentMember(documentSession);
                var gmRooms = documentSession.GetRoomsByOwner(currentMember.Id);
                var playerRooms = documentSession.GetRoomsByPlayer(currentMember.Id);
                return new DashboardResponse(gmRooms, playerRooms, alert);
            }

            return new MarketingPageResponse(alert);
        }
开发者ID:half-ogre,项目名称:rpg-rooms,代码行数:16,代码来源:HomeModule.cs

示例5: GetAcceptInvitationForm

        public static object GetAcceptInvitationForm(
            NancyContext context,
            IDocumentSession documentSession,
            string invitationCode)
        {
            context.Ensure("context");
            documentSession.Ensure("documentSession");

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

            var playerInvitation = documentSession.GetPlayerInvitationByCode(invitationCode);
            if (playerInvitation == null || playerInvitation.Used)
                return 404;

            var room = documentSession.GetRoomById(playerInvitation.RoomId);
            if (room == null)
                return 404;

            return new AcceptInvitationFormResponse(room, invitationCode);
        }
开发者ID:half-ogre,项目名称:rpg-rooms,代码行数:21,代码来源:AcceptInvitationFormModule.cs

示例6: PostRoom

        static object PostRoom(
            NancyContext context,
            IDocumentSession documentSession,
            string title,
            string slug,
            string description)
        {
            context.Ensure("context");
            documentSession.Ensure("documentSession");

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

            var errors = new List<string>();
            errors.AddRange(fn.ValidateRequired("Title", title));
            errors.AddRange(fn.ValidateLength("Title", title, 128));
            errors.AddRange(fn.ValidateRequired("Slug", slug));
            errors.AddRange(fn.ValidateLength("Slug", slug, 128));
            errors.AddRange(fn.ValidateFormat("Slug", slug, new Regex("[a-z][a-z0-9_-]+")));
            if (description != null)
                errors.AddRange(fn.ValidateLength("Description", description, 1024));

            var existingRoom =documentSession.GetRoomBySlug(slug);
            if (existingRoom != null)
                errors.Add(Strings.NotAvailable("slug", slug));

            existingRoom = documentSession.GetRoomByTitle(title);
            if (existingRoom != null)
                errors.Add(Strings.NotAvailable("title", title));

            if (errors.Count > 0)
                return context.ModelWithStatus(new CreateRoomFormResponse(title, slug, description, errors), 400);

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

            var room = documentSession.CreateRoom(currentMember.Id, slug, title, description);

            return context.Redirect(Paths.Room(room.Slug));
        }
开发者ID:half-ogre,项目名称:rpg-rooms,代码行数:40,代码来源:RoomsModule.cs

示例7: PostPost

        static object PostPost(
            NancyContext context,
            IDocumentSession documentSession,
            IMailSender mailSender,
            string slug,
            string source)
        {
            context.Ensure("context");
            documentSession.Ensure("documentSession");

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

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

            var room = documentSession.GetRoomBySlug(slug);
            if (room == null)
                return 404;

            if (String.IsNullOrEmpty(source))
                return 400;

            var currentMember = context.GetCurrentMember(documentSession);

            if (!room.CanPost(currentMember))
                return 403;

            var output = fn.HandlePost(documentSession, currentMember, room, source);

            if (output == null)
                output = new[] { InvalidPostHandlerOuput };

            if (output.Length > 0)
                return new SlashCommandOutputResponse(output);

            return 204;
        }
开发者ID:half-ogre,项目名称:rpg-rooms,代码行数:38,代码来源:PostsModule.cs

示例8: PostPlayer

        public static object PostPlayer(
            NancyContext context,
            IDocumentSession documentSession,
            IMailSender mailSender,
            string roomSlug,
            string invitationCode,
            string characterName,
            string characterAvatarUrl)
        {
            context.Ensure("context");
            documentSession.Ensure("documentSession");
            mailSender.Ensure("mailSender");

            if (string.IsNullOrEmpty(roomSlug))
                return 404;

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

            var room = documentSession.GetRoomBySlug(roomSlug);
            if (room == null)
                return 404;

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

            var errors = new List<string>();

            errors.AddRange(fn.ValidateRequired("Invitation code", invitationCode));
            var playerInvitation = documentSession.GetPlayerInvitationByCode(invitationCode);
            if (playerInvitation == null)
                errors.Add("The invitation code is not valid.");

            if (playerInvitation != null && playerInvitation.Used)
                errors.Add("The invitation code has already been used.");

            errors.AddRange(fn.ValidateRequired("Character Name", characterName));
            errors.AddRange(fn.ValidateLength("Character Name", characterName, 64));
            errors.AddRange(fn.ValidateFormat("Character Name", characterName, new Regex("^[a-z][a-z0-9 .'-]+$", RegexOptions.IgnoreCase)));

            if (!string.IsNullOrEmpty(characterAvatarUrl))
                errors.AddRange(fn.ValidateUrl("Avatar URL", characterAvatarUrl));

            var existingPlayer = room.Players.FirstOrDefault(p => p.CharacterName.Equals(characterName, StringComparison.OrdinalIgnoreCase));
            if (existingPlayer != null)
                errors.Add(Strings.NotAvailable("character name", characterName));

            if (errors.Count > 0)
                return context.ModelWithStatus(new AcceptInvitationFormResponse(room, invitationCode, characterName, characterAvatarUrl, errors), 400);

            var player = new Player
            {
                CharacterAvatarUrl = characterAvatarUrl,
                CharacterName = characterName,
                MemberAlias = currentMember.Alias,
                MemberId = currentMember.Id,
                MemberEmailAddress = currentMember.EmailAddress,
                RoomId = room.Id
            };

            room.Players.Add(player);

            documentSession.UpdatePlayerInvitation(playerInvitation.Id, used: true);

            string text = Strings.Format("{0} joined the room as {1}.", player.MemberAlias, player.CharacterName);
            documentSession.CreatePost(mailSender, room.Id, currentMember.Id, null, null, "system", text);

            return context.Redirect(Paths.Room(room.Slug));
        }
开发者ID:half-ogre,项目名称:rpg-rooms,代码行数:69,代码来源:PlayersModule.cs


注:本文中的Nancy.NancyContext.IsSignedUp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。