예제 #1
0
        public void DeleteSatisfactionConfig()
        {
            Home home;

            using (UserManager <Client, int> manager = new ClientUserManager(new CustomUserStore(ctx)))
            {
                ctx.HomeSet.Add(home = new Home()
                {
                    Title             = "LaCorderieTest",
                    EstablishmentType = EEstablishmentType.BB,
                    Client            = manager.FindByEmail("*****@*****.**"),
                });
            }

            SatisfactionConfig toAdd;

            repo.Add(toAdd = new SatisfactionConfig()
            {
                Home  = home,
                Title = "ttt"
            });

            repo.Save();

            repo.Delete(toAdd);
            repo.Save();

            Assert.IsNull(ctx.SatisfactionConfigSet.FirstOrDefault(p => p.Home.Id == home.Id));
            Assert.IsNull(ctx.SatisfactionConfigQuestionSet.Include("SatisfactionConfig").FirstOrDefault(p => p.SatisfactionConfig.Id == toAdd.Id));
            Assert.IsNotNull(ctx.HomeSet.FirstOrDefault(p => p.Title == home.Title));
        }
예제 #2
0
 public void ForbiddenResource()
 {
     using (UserManager <Client, int> manager = new ClientUserManager(new CustomUserStore(ctx)))
     {
         Assert.IsNull(repo.GetFieldGroupById(1, manager.FindByEmail("*****@*****.**").Id));
     }
 }
예제 #3
0
 public void GetRoomCategoryWithBadHomeId()
 {
     using (UserManager <Client, int> manager = new ClientUserManager(new CustomUserStore(ctx)))
     {
         Assert.IsNull(repo.GetRoomCategoryById(1, manager.FindByEmail("*****@*****.**").Id));
     }
 }
예제 #4
0
        protected override bool IsAuthorized(HttpActionContext actionContext)
        {
            if (actionContext == null)
            {
                throw new ArgumentNullException("actionContext");
            }

            IPrincipal user = actionContext.ControllerContext.RequestContext.Principal;

            if (user == null || user.Identity == null || !user.Identity.IsAuthenticated)
            {
                return(false);
            }
            if (Users.Length > 0 && !(Users.IndexOf(user.Identity.Name, StringComparison.OrdinalIgnoreCase) >= 0))
            {
                return(false);
            }
            if (Roles.Length > 0)
            {
                IDependencyScope  Scope       = actionContext.Request.GetOwinContext().Get <IDependencyScope>();
                ClientUserManager UserManager = Scope.GetService(typeof(ClientUserManager)) as ClientUserManager;
                var client    = UserManager.FindByEmailAsync(user.Identity.Name).Result;
                var GroupList = UserManager.GetRolesAsync(client.Id).Result;
                var listRoles = Roles.Split(',');
                if (listRoles.Where(x => GroupList.Any(y => y.Equals(x))).Count() == 0)
                {
                    return(false);
                }
            }
            return(true);
        }
예제 #5
0
        public void UpdateUser()
        {
            var user  = new UserInfo("Nickname", "Phonetic", "Username", 1, 2, true);
            var user2 = new UserInfo("Nickname2", "Phonetic2", "Username2", 2, 3, false);

            var manager = new ClientUserManager();

            manager.Join(user);

            user  = new UserInfo("NicknameU", "PhoneticU", "Username2", 1, 2, false);
            user2 = new UserInfo("Nickname2U", "Phonetic2U", "Username2", 2, 3, false);

            manager.Update(user);

            Assert.IsTrue(manager.GetIsJoined(user));
            Assert.AreEqual(user, manager[user.UserId]);
            Assert.AreEqual(user.Nickname, manager[user.UserId].Nickname);
            Assert.AreEqual(user.Phonetic, manager[user.UserId].Phonetic);
            Assert.AreEqual(user.Username, manager[user.UserId].Username);
            Assert.AreEqual(user.UserId, manager[user.UserId].UserId);
            Assert.AreEqual(user.CurrentChannelId, manager[user.UserId].CurrentChannelId);
            Assert.AreEqual(user.IsMuted, manager[user.UserId].IsMuted);

            manager.Update(user2);

            Assert.IsTrue(manager.GetIsJoined(user2));
            Assert.AreEqual(user2, manager[user2.UserId]);
            Assert.AreEqual(user2.Nickname, manager[user2.UserId].Nickname);
            Assert.AreEqual(user2.Phonetic, manager[user2.UserId].Phonetic);
            Assert.AreEqual(user2.Username, manager[user2.UserId].Username);
            Assert.AreEqual(user2.UserId, manager[user2.UserId].UserId);
            Assert.AreEqual(user2.CurrentChannelId, manager[user2.UserId].CurrentChannelId);
            Assert.AreEqual(user2.IsMuted, manager[user2.UserId].IsMuted);
        }
예제 #6
0
 public void GetPeopleWithBadHomeId()
 {
     using (UserManager<Client, int> manager = new ClientUserManager(new CustomUserStore(ctx)))
     {
         Assert.IsNull(repo.GetPeopleById(1, manager.FindByEmail("*****@*****.**").Id));
     }
 }
예제 #7
0
        public static async Task <string[]> MainAsync()
        {
            RestClient.SetDomain("https://*****:*****@gmail.com",
                FName           = $"Name{random}",
                LName           = $"LName{random}",
                Password        = $"Password{random}",
                ConfirmPassword = $"Password{random}"
            });


            ThingDto dto = things.Get(1);

            dto.Household = households.Get(dto.HouseholdId);
            Console.WriteLine(JsonConvert.SerializeObject(dto));


            //      dto = complete thing, ready for use


            return("Oi");
        }
        public void DeleteSatisfactionConfig()
        {
            Home home;

            using (UserManager<Client, int> manager = new ClientUserManager(new CustomUserStore(ctx)))
            {
                ctx.HomeSet.Add(home = new Home()
                {
                    Title = "LaCorderieTest",
                    EstablishmentType = EEstablishmentType.BB,
                    Client = manager.FindByEmail("*****@*****.**"),
                });
            }

            SatisfactionConfig toAdd;

            repo.Add(toAdd = new SatisfactionConfig()
            {
                Home = home,
                Title = "ttt"
            });

            repo.Save();

            repo.Delete(toAdd);
            repo.Save();

            Assert.IsNull(ctx.SatisfactionConfigSet.FirstOrDefault(p => p.Home.Id == home.Id));
            Assert.IsNull(ctx.SatisfactionConfigQuestionSet.Include("SatisfactionConfig").FirstOrDefault(p => p.SatisfactionConfig.Id == toAdd.Id));
            Assert.IsNotNull(ctx.HomeSet.FirstOrDefault(p => p.Title == home.Title));
        }
예제 #9
0
 public void Init()
 {
     ctx  = EFContext.CreateContext();
     repo = new HomeConfigRepository(ctx);
     using (UserManager <Client, int> manager = new ClientUserManager(new CustomUserStore(ctx)))
     {
         entity = new HomeConfig()
         {
             Home = new Home()
             {
                 Title             = "LaCorderieTest",
                 EstablishmentType = EEstablishmentType.BB,
                 Client            = manager.FindByEmail("*****@*****.**"),
             },
             AutoSendSatisfactionEmail = false,
             DepositNotifEnabled       = false,
             Devise                  = "$",
             EnableDinner            = false,
             EnableDisplayActivities = false,
             EnableDisplayMeals      = false,
             EnableDisplayProducts   = false,
             EnableDisplayRooms      = false,
             EnableReferencing       = false,
             FollowStockEnable       = false,
             HourFormat24            = true
         };
     }
     repo.Add(entity);
     repo.Save();
 }
예제 #10
0
 public void Init()
 {
     ctx = EFContext.CreateContext();
     repo = new HomeConfigRepository(ctx);
     using (UserManager<Client, int> manager = new ClientUserManager(new CustomUserStore(ctx)))
     {
         entity = new HomeConfig()
         {
             Home = new Home()
             {
                 Title = "LaCorderieTest",
                 EstablishmentType = EEstablishmentType.BB,
                 Client = manager.FindByEmail("*****@*****.**"),
             },
             AutoSendSatisfactionEmail = false,
             DepositNotifEnabled = false,
             Devise = "$",
             EnableDinner = false,
             EnableDisplayActivities = false,
             EnableDisplayMeals = false,
             EnableDisplayProducts = false,
             EnableDisplayRooms = false,
             EnableReferencing = false,
             FollowStockEnable = false,
             HourFormat24 = true
         };
     }
     repo.Add(entity);
     repo.Save();
 }
예제 #11
0
 public void ForbiddenResource()
 {
     using (UserManager <Client, int> manager = new ClientUserManager(new CustomUserStore(ctx)))
     {
         Assert.IsNull(repo.GetRoomById(ctx.RoomSet.FirstOrDefault(x => x.Title == "Melanie").Id, (int)manager.FindByEmail("*****@*****.**").DefaultHomeId));
     }
 }
예제 #12
0
 public void ForbiddenResource()
 {
     using (UserManager<Client, int> manager = new ClientUserManager(new CustomUserStore(ctx)))
     {
         Assert.IsNull(repo.GetRoomSupplementById(1, manager.FindByEmail("*****@*****.**").Id));
     }
 }
예제 #13
0
 public void ForbiddenResource()
 {
     using (UserManager<Client, int> manager = new ClientUserManager(new CustomUserStore(ctx)))
     {
         Assert.IsNull(repo.GetRoomById(ctx.RoomSet.FirstOrDefault(x => x.Title == "Melanie").Id, (int)manager.FindByEmail("*****@*****.**").DefaultHomeId));
     }
 }
예제 #14
0
 public void GetForbiddenResource()
 {
     using (UserManager<Client, int> manager = new ClientUserManager(new CustomUserStore(ctx)))
     {
         Tax get = repo.GetTaxById(1, manager.FindByEmail("*****@*****.**").Id);
         Assert.IsNull(get);
     }
 }
예제 #15
0
 public void GetForbiddenResource()
 {
     using (UserManager <Client, int> manager = new ClientUserManager(new CustomUserStore(ctx)))
     {
         Tax get = repo.GetTaxById(1, manager.FindByEmail("*****@*****.**").Id);
         Assert.IsNull(get);
     }
 }
예제 #16
0
        public void DepartNonJoined()
        {
            var user = new UserInfo("Nickname", "Phonetic", "Username", 1, 2, true);

            var manager = new ClientUserManager();

            Assert.IsFalse(manager.GetIsJoined(user));
            Assert.IsFalse(manager.Depart(user));
        }
예제 #17
0
        public void ShouldFailBecauseOfNotPermitted()
        {
            using (UserManager<Client, int> manager = new ClientUserManager(new CustomUserStore(ctx)))
            {
                RoomCategory get = repo.GetRoomCategoryById(ctx.RoomCategorySet.FirstOrDefault(p => p.Title == "Cat1").Id, (int)manager.FindByEmail("*****@*****.**").DefaultHomeId);

                Assert.IsNull(get);
            }
        }
예제 #18
0
 public void ForbiddenResource()
 {
     using (UserManager <Client, int> manager = new ClientUserManager(new CustomUserStore(ctx)))
     {
         Assert.IsNull(repo.GetDepositById(1, manager.FindByEmail("*****@*****.**").Id));
         Assert.IsNull(repo.GetDepositByBookingId(1, 8590, (int)ctx.HomeSet.FirstOrDefault(x => x.Title == "LaCorderie").ClientId));
         Assert.IsNull(repo.GetDepositByBookingId(1, 1, manager.FindByEmail("*****@*****.**").Id));
     }
 }
예제 #19
0
 public void ShouldNotGetBecauseOfNotPermitted()
 {
     //Bed get = repo.GetBedById(ctx.BedSet.FirstOrDefault(p => p.NumberPeople == 2).Id, (int)ctx.ClientSet.FirstOrDefault(p => p.Email == "*****@*****.**").DefaultHomeId);
     using (ClientUserManager manager = new ClientUserManager(new CustomUserStore(ctx)))
     {
         Bed get = repo.GetBedById(ctx.BedSet.FirstOrDefault(p => p.NumberPeople == 2).Id, (int)manager.FindByEmail("*****@*****.**").DefaultHomeId);
         Assert.IsNull(get);
     }
 }
예제 #20
0
 public void ShouldNotGetBecauseOfNotPermitted()
 {
     //Bed get = repo.GetBedById(ctx.BedSet.FirstOrDefault(p => p.NumberPeople == 2).Id, (int)ctx.ClientSet.FirstOrDefault(p => p.Email == "*****@*****.**").DefaultHomeId);
     using (ClientUserManager manager = new ClientUserManager(new CustomUserStore(ctx)))
     {
         Bed get = repo.GetBedById(ctx.BedSet.FirstOrDefault(p => p.NumberPeople == 2).Id, (int)manager.FindByEmail("*****@*****.**").DefaultHomeId);
         Assert.IsNull(get);
     }
 }
예제 #21
0
 public void ForbiddenResource()
 {
     using (UserManager<Client, int> manager = new ClientUserManager(new CustomUserStore(ctx)))
     {
         Assert.IsNull(repo.GetDepositById(1, manager.FindByEmail("*****@*****.**").Id));
         Assert.IsNull(repo.GetDepositByBookingId(1, 8590, (int)ctx.HomeSet.FirstOrDefault(x => x.Title == "LaCorderie").ClientId));
         Assert.IsNull(repo.GetDepositByBookingId(1, 1, manager.FindByEmail("*****@*****.**").Id));
     }
 }
예제 #22
0
        public void ShouldFailBecauseOfNotPermitted()
        {
            using (UserManager <Client, int> manager = new ClientUserManager(new CustomUserStore(ctx)))
            {
                RoomCategory get = repo.GetRoomCategoryById(ctx.RoomCategorySet.FirstOrDefault(p => p.Title == "Cat1").Id, (int)manager.FindByEmail("*****@*****.**").DefaultHomeId);

                Assert.IsNull(get);
            }
        }
예제 #23
0
        public MainWindow()
        {
            RestClient.SetDomain("https://localhost:44371");

            manager = new ClientUserManager();

            InitializeComponent();
            GoToLoginPage();
        }
예제 #24
0
        public void IndexerPresent()
        {
            var user = new UserInfo("Nickname", "Phonetic", "Username", 1, 2, true);

            var manager = new ClientUserManager();

            manager.Join(user);

            Assert.AreEqual(user, manager[user.UserId]);
        }
예제 #25
0
        public void ForbiddenResource()
        {
            repo.Add(b);
            repo.Save();

            using (UserManager<Client, int> manager = new ClientUserManager(new CustomUserStore(ctx)))
            {
                Assert.IsNull(repo.GetBookingById(b.Id, manager.FindByEmail("*****@*****.**").Id));
            }
        }
예제 #26
0
        public void ForbiddenResource()
        {
            repo.Add(b);
            repo.Save();

            using (UserManager <Client, int> manager = new ClientUserManager(new CustomUserStore(ctx)))
            {
                Assert.IsNull(repo.GetBookingById(b.Id, manager.FindByEmail("*****@*****.**").Id));
            }
        }
예제 #27
0
        public LoginPage(MainWindow loginWindow)
        {
            if (userManager == null)
            {
                userManager = new ClientUserManager();
            }

            InitializeComponent();
            this.mainWindow = loginWindow;
        }
예제 #28
0
        public void GetBedWithBadHomeId()
        {
            repo.Add(entity);
            repo.Save();

            using (UserManager<Client, int> manager = new ClientUserManager(new CustomUserStore(ctx)))
            {
                Assert.IsNull(repo.GetBedById(entity.Id, manager.FindByEmail("*****@*****.**").Id));
            }
        }
예제 #29
0
        public void ForbiddenResource()
        {
            repo.Add(entity);
            repo.Save();

            using (ClientUserManager manager = new ClientUserManager(new CustomUserStore(ctx)))
            {
                Assert.IsNull(repo.GetAdditionalBookingById(entity.Id, manager.FindByEmail("*****@*****.**").Id));
            }
        }
예제 #30
0
        public void GetBedWithBadHomeId()
        {
            repo.Add(entity);
            repo.Save();

            using (UserManager <Client, int> manager = new ClientUserManager(new CustomUserStore(ctx)))
            {
                Assert.IsNull(repo.GetBedById(entity.Id, manager.FindByEmail("*****@*****.**").Id));
            }
        }
예제 #31
0
        public RegisterViewModel(IFrameNavigationService navigationService)
        {
            _navigationService = navigationService;

            User         = new User();
            _userManager = new ClientUserManager();

            RegisterCommand = new RelayCommand(Register);
            LoginCommand    = new RelayCommand(Login);
        }
예제 #32
0
        public ClientTrading(NetClient netClient, ClientAuthenticator authenticator, ClientUserManager userManager)
        {
            this.netClient     = netClient;
            this.authenticator = authenticator;
            this.userManager   = userManager;

            this.activeTrades = new Dictionary <string, Trade>();

            netClient.RegisterPacketHandler(MODULE_NAME, packetHandler);
            netClient.OnDisconnect += disconnectHandler;
        }
예제 #33
0
        public void IndexerNotPresent()
        {
            var user  = new UserInfo("Nickname", "Phonetic", "Username", 1, 2, true);
            var user2 = new UserInfo("Nickname2", "Phonetic2", "Username2", 2, 3, false);

            var manager = new ClientUserManager();

            manager.Join(user);

            Assert.AreEqual(null, manager[user2.UserId]);
        }
예제 #34
0
 //ctor
 public ChatViewModel(IFrameNavigationService navigationService)
 {
     _navigationService = navigationService;
     _userManager       = new ClientUserManager();
     _chatManager       = new ClientChatManager();
     UserToChatWith     = $"You are talking with: { ClientUserManager.UserToChatWith}";
     UserTitle          = $"Welcome {ClientUserManager.CurrentUser}";
     SendMessageCommand = new RelayCommand(SandMessage);
     BackCommand        = new RelayCommand(Back);
     _chatManager.RegisterSendMessageEvent(ReciveMessage);
     _chatManager.RegisterUserDisconnectedEvent(ReturnToContactPage);
 }
예제 #35
0
        public ClientChat(NetClient netClient, ClientAuthenticator authenticator, ClientUserManager userManager)
        {
            this.netClient     = netClient;
            this.authenticator = authenticator;
            this.userManager   = userManager;

            this.messageHistory          = new List <ClientChatMessage>();
            this.messageCountAtLastCheck = 0;

            netClient.RegisterPacketHandler(MODULE_NAME, packetHandler);
            netClient.OnDisconnect += disconnectHandler;
        }
예제 #36
0
        public void Join()
        {
            var user = new UserInfo("Nickname", "Phonetic", "Username", 1, 2, true);

            var manager = new ClientUserManager();

            manager.Join(user);

            Assert.IsTrue(manager.GetIsJoined(user));
            Assert.IsTrue(((IEnumerable <IUserInfo>)manager).Contains(user));
            Assert.AreEqual(user, manager[user.UserId]);
        }
예제 #37
0
        public void UpdateEmpty()
        {
            var user  = new UserInfo("Nickname", "Phonetic", "Username", 1, 2, true);
            var user2 = new UserInfo("Nickname2", "Phonetic2", "Username2", 2, 3, false);

            var manager = new ClientUserManager();

            manager.Update(new [] { user, user2 });

            Assert.IsTrue(manager.GetIsJoined(user));
            Assert.IsTrue(manager.GetIsJoined(user2));
        }
예제 #38
0
        public async override Task Invoke(IOwinContext context)
        {
            if (context.Authentication.User != null && !String.IsNullOrWhiteSpace(context.Authentication.User.Identity.Name) && context.Authentication.User.Identity.IsAuthenticated)
            {
                IDependencyScope  Scope       = context.Get <IDependencyScope>();
                ClientUserManager UserManager = Scope.GetService(typeof(ClientUserManager)) as ClientUserManager;
                var userClient = await UserManager.FindByEmailAsync(context.Authentication.User.Identity.Name);

                if (userClient.Locale != null && !string.IsNullOrEmpty(userClient.Locale))
                {
                    Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(userClient.Locale);
                }
            }
            await Next.Invoke(context);
        }
예제 #39
0
        public UserCreatePage(MainWindow mainWindow)
        {
            if (userRest == null)
            {
                userRest = new UserRest();
            }

            if (userManager == null)
            {
                userManager = new ClientUserManager();
            }

            InitializeComponent();
            this.mainWindow = mainWindow;
        }
예제 #40
0
        //ctor
        public ContactsViewModel(IFrameNavigationService navigationService)
        {
            _navigationService  = navigationService;
            _userManager        = new ClientUserManager();
            _interactionManager = new ClientInteractionManager();

            ContactList = ConvertUserForUserView.ConvertUser(_userManager.GetContactList());

            _userManager.RegisterNotifyEvent(ContactUptaded);
            _interactionManager.RegisterInvitationResponseEvent(HandleUserResponse);
            _interactionManager.RegisterChatRequestEvent(AgreeChatRequest);

            LogoutCommand   = new RelayCommand(Logout);
            OpenChatCommand = new RelayCommand(OpenChat);
            OpenGameCommand = new RelayCommand(OpenGame);
            UserTitle       = $"Welcome {ClientUserManager.CurrentUser}";
        }
예제 #41
0
        public void ExtensionGetIsJoinedUsername()
        {
            var user  = new UserInfo("Nickname", "Phonetic", "Username", 1, 2, true);
            var user2 = new UserInfo("Nickname2", "Phonetic", "Username2", 2, 3, false);

            var manager = new ClientUserManager();

            manager.Join(user);

            Assert.IsTrue(manager.GetIsJoined(user));
            Assert.IsFalse(manager.GetIsJoined(user2));

            manager.Join(user2);
            Assert.IsTrue(manager.GetIsJoined(user2));

            manager.Depart(user);
            Assert.IsFalse(manager.GetIsJoined(user));
        }
예제 #42
0
 public ClientRepository(ManahostManagerDAL ctx)
 {
     _ctx = ctx;
     _userManager = new ClientUserManager(new CustomUserStore(_ctx));
 }
        public void ForbiddenResource()
        {
            repo.Add(entity);
            repo.Save();

            using (ClientUserManager manager = new ClientUserManager(new CustomUserStore(ctx)))
            {
                Assert.IsNull(repo.GetAdditionalBookingById(entity.Id, manager.FindByEmail("*****@*****.**").Id));
            }
        }