Esempio n. 1
0
        public async Task <SnapshotProfileModel> EditProfile([FromBody] SnapshotProfileModel profileModel)
        {
            profileModel = await _accountService.EditProfile(AccountName, profileModel);
            await Log($"Updated profile with name: {profileModel.Name}");

            return(profileModel);
        }
Esempio n. 2
0
        public async Task <SnapshotProfileModel> EditProfile([FromBody] SnapshotProfileModel profileModel)
        {
            profileModel = await _accountService.EditProfile(AccountName, profileModel);

            LogDebug($"Updated profile with name: {profileModel.Name} in " + _timer.ElapsedMilliseconds + " ms.");
            return(profileModel);
        }
Esempio n. 3
0
        public async Task <SnapshotProfileModel> AddProfile([FromBody] SnapshotProfileModel profileModel)
        {
            profileModel = await _accountService.AddProfile(AccountName, profileModel);
            await Log($"Added profile with name: {profileModel.Name}");

            var group = await _groupService.GetGroupForConnection(ConnectionId);

            if (group != null)
            {
                await Clients.OthersInGroup(group.Name).SendAsync("OnAddProfile", ConnectionId, profileModel);
            }

            return(profileModel);
        }
        public async Task <SnapshotProfileModel> ProfileExists(string accountName, SnapshotProfileModel profileModel)
        {
            var account = await _accountRepository.GetAccounts(a => a.Name == accountName).Include(account => account.Profiles).FirstOrDefaultAsync();

            if (account == null)
            {
                throw new Exception("Can't find account");
            }

            var profile = account.Profiles.FirstOrDefault(profile => profile.ClientId == profileModel.ClientId);

            if (profile == null)
            {
                throw new Exception("Can't find profile");
            }

            return(_mapper.Map <SnapshotProfileModel>(profile));
        }
        public async Task <SnapshotProfileModel> AddProfile(string accountName, SnapshotProfileModel profileModel)
        {
            var account = await _accountRepository.GetAccounts(account => account.Name == accountName).Include(account => account.Profiles).FirstOrDefaultAsync();

            if (account == null)
            {
                throw new Exception("Can't find account");
            }

            var profile = _mapper.Map <SnapshotProfile>(profileModel);

            profile.Created = DateTime.UtcNow;

            account.Profiles.Add(profile);
            await _accountRepository.SaveChangesAsync();

            return(_mapper.Map <SnapshotProfileModel>(profile));
        }
Esempio n. 6
0
        public async Task CreateReciveAndDeleteProfile()
        {
            var account = new AccountModel()
            {
                ClientId   = TestHelper.GenerateUUID(),
                Name       = TestHelper.GetRandomString(),
                Role       = Role.Admin,
                Characters = new List <CharacterModel>(),
                Verified   = true
            };

            account.AccessToken = AuthHelper.GenerateToken(_fixture.Secret, account);

            account = await _fixture.AccountService.AddAccount(account);

            var newProfile = new SnapshotProfileModel()
            {
                ActiveLeagueId      = TestHelper.GenerateUUID(),
                ActivePriceLeagueId = TestHelper.GenerateUUID(),
                ActiveStashTabIds   = new List <string>()
                {
                },
                ClientId  = TestHelper.GenerateUUID(),
                Name      = TestHelper.GetRandomString(),
                Snapshots = new List <SnapshotModel>()
                {
                }
            };

            newProfile = await _fixture.AccountService.AddProfile(account.Name, newProfile);

            var addedProfile = await _fixture.AccountService.GetProfile(newProfile.ClientId);

            await _fixture.AccountService.RemoveProfile(account.Name, newProfile.ClientId);

            var removedProfile = await _fixture.AccountService.GetProfile(newProfile.ClientId);

            Assert.NotNull(newProfile.ClientId);
            Assert.Equal(newProfile.ClientId, addedProfile.ClientId);
            Assert.Null(removedProfile);
        }
Esempio n. 7
0
        public async Task AddSnapshot()
        {
            var account = new AccountModel()
            {
                ClientId   = TestHelper.GenerateUUID(),
                Name       = TestHelper.GetRandomString(),
                Role       = Role.Admin,
                Characters = new List <CharacterModel>(),
                Verified   = true
            };

            account = await _fixture.AccountService.AddAccount(account);

            var profile = new SnapshotProfileModel()
            {
                ClientId          = TestHelper.GenerateUUID(),
                ActiveLeagueId    = TestHelper.GenerateUUID(),
                ActiveStashTabIds = new List <string>()
                {
                },
                ActivePriceLeagueId = TestHelper.GenerateUUID(),
                Name      = TestHelper.GetRandomString(),
                Snapshots = new List <SnapshotModel>()
                {
                }
            };

            profile = await _fixture.AccountService.AddProfile(account.Name, profile);

            var snapshot = new SnapshotModel()
            {
                ClientId  = TestHelper.GenerateUUID(),
                StashTabs = new List <StashtabModel>()
            };

            snapshot = await _fixture.SnapshotService.AddSnapshot(profile.ClientId, snapshot);

            var stashtabs = new List <StashtabModel>()
            {
                new StashtabModel()
                {
                    ClientId    = TestHelper.GenerateUUID(),
                    Color       = TestHelper.GetRandomString(),
                    Index       = 0,
                    Name        = TestHelper.GetRandomString(),
                    PricedItems = new List <PricedItemModel>()
                },
                new StashtabModel()
                {
                    ClientId    = TestHelper.GenerateUUID(),
                    Color       = TestHelper.GetRandomString(),
                    Index       = 1,
                    Name        = TestHelper.GetRandomString(),
                    PricedItems = new List <PricedItemModel>()
                }
            };

            foreach (var stashtab in stashtabs)
            {
                var returnedStashtab = await _fixture.SnapshotService.AddStashtab(snapshot.ClientId, stashtab);

                Assert.NotNull(returnedStashtab.ClientId);
            }

            var retrivedAccount = await _fixture.AccountService.GetAccount(account.Name);

            Assert.NotNull(retrivedAccount.ClientId);
            Assert.NotNull(retrivedAccount.Profiles[0].ClientId);
            Assert.NotNull(retrivedAccount.Profiles[0].Snapshots[0].ClientId);
            Assert.NotNull(retrivedAccount.Profiles[0].Snapshots[0].StashTabs[0].ClientId);
            Assert.NotNull(retrivedAccount.Profiles[0].Snapshots[0].StashTabs[1].ClientId);
        }