Exemplo n.º 1
0
 public AppDomainService()
 {
     _context       = new WindowsStoreContext();
     AppBiz         = new AppBiz(_context);
     PlatformBiz    = new PlatformBiz(_context);
     AppCategoryBiz = new AppCategoryBiz(_context);
     AppVersionBiz  = new AppVersionBiz(_context);
     ScreenshotBiz  = new ScreenshotBiz(_context);
 }
Exemplo n.º 2
0
        public void RegisterAppPlatformSpecification(AppPlatformSpecificationDataContract appPlatformSpecificationDataContract)
        {
            // update CpuArchitecture
            AppBiz.UpdatePartially(appPlatformSpecificationDataContract.ToApp(), a => a.CpuArchitectureFlags);


            // update AppPlatformCategories
            // fetch app
            var app = _context.Apps.Include("Platforms").Single(a => a.Id == appPlatformSpecificationDataContract.AppId);

            var oldPlatforms = app.Platforms.ToList();

            //var person = PersonBiz.Single(p => p.Id == userId);
            //var role = RoleBiz.Single(r => r.Name == roleName);

            //person.Roles.Add(role);
            // remove all app platforms
            foreach (var platform in oldPlatforms)
            {
                app.Platforms.Remove(platform);
            }

            // fetch all platforms
            // var platformCategories = _context.Platforms.ToList();

            var newPlatforms =
                PlatformBiz.Where(p => appPlatformSpecificationDataContract.PlatformCategories.Contains(p.Id));

            // add platforms that exist in list into appPltforms
            foreach (var platform in newPlatforms)
            {
                app.Platforms.Add(platform);
            }

            _context.SaveChanges();
        }