예제 #1
0
        public async Task <SnapshotModel> AddSnapshot(string profileClientId, SnapshotModel snapshotModel)
        {
            var snapshot = _mapper.Map <Snapshot>(snapshotModel);

            await _snapshotRepository.RemovePricedItems(profileClientId);

            snapshot.ProfileClientId = profileClientId;

            await _snapshotRepository.AddSnapshots(new List <Snapshot>() { snapshot });

            snapshot.StashTabs.Select(stashtab => {
                stashtab.SnapshotClientId        = snapshot.ClientId;
                stashtab.SnapshotProfileClientId = profileClientId;
                return(stashtab);
            }).ToList();

            await _snapshotRepository.AddStashtabs(snapshot.StashTabs.ToList());

            snapshot.StashTabs.ForEach(
                stashtab => stashtab.PricedItems.Select(pricedItem => {
                pricedItem.StashtabClientId        = stashtab.ClientId;
                pricedItem.SnapshotProfileClientId = profileClientId;
                return(stashtab);
            }).ToList());

            await _snapshotRepository.AddPricedItems(snapshot.StashTabs.SelectMany(s => s.PricedItems).ToList());

            return(_mapper.Map <SnapshotModel>(snapshot));
        }
예제 #2
0
        public async Task <SnapshotModel> AddSnapshot(string profileClientId, SnapshotModel snapshotModel)
        {
            var snapshot = _mapper.Map <Snapshot>(snapshotModel);

            // todo: readd when we want to persist stash tabs and items for historical reasons

            //await _snapshotRepository.RemovePricedItems(profileClientId);

            snapshot.ProfileClientId = profileClientId;

            await _snapshotRepository.AddSnapshots(new List <Snapshot>() { snapshot });

            // todo: readd when we want to persist stash tabs and items for historical reasons

            //snapshot.StashTabs.Select(stashtab => {
            //    stashtab.SnapshotClientId = snapshot.ClientId;
            //    stashtab.SnapshotProfileClientId = profileClientId;
            //    return stashtab;
            //}).ToList();

            //await _snapshotRepository.AddStashtabs(snapshot.StashTabs.ToList());

            //snapshot.StashTabs.ForEach(
            //    stashtab => stashtab.PricedItems.Select(pricedItem => {
            //        pricedItem.StashtabClientId = stashtab.ClientId;
            //        pricedItem.SnapshotProfileClientId = profileClientId;
            //        return stashtab;
            //    }).ToList());

            //await _snapshotRepository.AddPricedItems(snapshot.StashTabs.SelectMany(s => s.PricedItems).ToList());

            return(_mapper.Map <SnapshotModel>(snapshot));
        }
예제 #3
0
        public async Task <SnapshotModel> AddSnapshot(string profileClientId, SnapshotModel snapshotModel)
        {
            var snapshot = _mapper.Map <Snapshot>(snapshotModel);

            await _snapshotRepository.RemovePricedItems(profileClientId);

            var profile = await _accountRepository.GetProfiles(profile => profile.ClientId == profileClientId)
                          .Include(profile => profile.Snapshots)
                          .AsNoTracking()
                          .FirstAsync();

            snapshot.ProfileId = profile.Id;

            await _snapshotRepository.AddSnapshots(new List <Snapshot>() { snapshot });

            return(_mapper.Map <SnapshotModel>(snapshot));
        }