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); }
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"); } }
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 }); }