コード例 #1
0
        public SharedListModel Handle(GetSharedListRequest message)
        {
            if (context.Set <WishList>().Any(wl => wl.Id == message.ListId && wl.UserId == message.UserId))
            {
                throw new FriendlyException(EventIds.OwnerAccessingSharedList, "Du kan ikke se din egen liste");
            }
            accessChecker.CheckWishListInvitations(message.ListId, message.UserId);

            var sharedListModel = context.Set <WishList>()
                                  .Where(wl => wl.Id == message.ListId)
                                  .ProjectTo <SharedListModel>(mapper.MapperConfiguration)
                                  .SingleOrThrow(new FriendlyException(EventIds.SharedListMissing, "Listen finnes ikke"));

            return(sharedListModel);
        }
コード例 #2
0
ファイル: AccessChecker.cs プロジェクト: devchild/Gaver
 public void CheckNotOwner(int wishListId, int userId)
 {
     if (context.Set <WishList>().Any(wl => wl.Id == wishListId && wl.UserId == userId))
     {
         throw new FriendlyException(EventIds.OwnerAccessingSharedList, "Du kan ikke se din egen liste");
     }
 }
コード例 #3
0
ファイル: GetMessages.cs プロジェクト: devchild/Gaver
        public ChatModel Handle(GetMessagesRequest message)
        {
            var messages = context.Set <ChatMessage>()
                           .Where(cm => cm.WishListId == message.WishListId)
                           .ProjectTo <ChatMessageModel>(mapper.MapperConfiguration).ToList();

            return(new ChatModel {
                Messages = messages
            });
        }