Beispiel #1
0
        //Projects the user information contained into uploadDTO over a new User object
        public User UserDotUploadDTO(UploadDTO uploadDTO)
        {
            User newUser = GenerateNewUserFromDTO(uploadDTO);

            if (GenerateControlIfDuplicateUserOnDB(newUser) == null)
            {
                newUser = _userRepository.AddEntityReturned(newUser);

                _playStoreDBContext.SaveChanges();
            }

            return(GenerateControlIfDuplicateUserOnDB(newUser));
        }
Beispiel #2
0
        public void AppDotUploadDTO(UploadDTO uploadDTO)
        {
            var tempApp = GenerateTempApp(uploadDTO);

            App checkApp = _playStoreDBContext.Apps.Where(x => x.LastUpdate == tempApp.LastUpdate).FirstOrDefault();

            if (checkApp == null)
            {
                //Add to Apps
                App tempTempApp = _appRepository.AddEntityReturned(tempApp);

                //tempApp = tempTempApp;

                _playStoreDBContext.SaveChanges();
            }

            tempApp = _playStoreDBContext.Apps.Where(x => x.LastUpdate == tempApp.LastUpdate).FirstOrDefault();
        }
Beispiel #3
0
        public void AddUpload(UploadDTO uploadDTO)
        {
            //check sul valore nullo ArgumentNullException



            //***************************************************

            var tempUser = new User()
            {
                Name    = uploadDTO.DeveloperName,
                Surname = uploadDTO.DeveloperSurname,
                Email   = uploadDTO.Email
            };

            User checkUser = _playStoreDBContext.Users.Where(x => x.Email == tempUser.Email).FirstOrDefault();

            if (checkUser == null)
            {
                //Add to Users
                User tempTempUser = _userRepository.AddEntityReturned(tempUser);

                //tempUser = tempTempUser;

                _playStoreDBContext.SaveChanges();
            }

            tempUser = _playStoreDBContext.Users.Where(x => x.Email == tempUser.Email).FirstOrDefault();

            //*****************************************************
            var tempApp = new App()
            {
                Name       = uploadDTO.AppName,
                Genre      = uploadDTO.Genre,
                LastUpdate = uploadDTO.LastUpdate,
                AppBrand   = uploadDTO.AppBrand
            };

            App checkApp = _playStoreDBContext.Apps.Where(x => x.LastUpdate == tempApp.LastUpdate).FirstOrDefault();

            if (checkApp == null)
            {
                //Add to Apps
                App tempTempApp = _appRepository.AddEntityReturned(tempApp);

                //tempApp = tempTempApp;

                _playStoreDBContext.SaveChanges();
            }

            tempApp = _playStoreDBContext.Apps.Where(x => x.LastUpdate == tempApp.LastUpdate).FirstOrDefault();

            //*****************************************************
            var tempCompatibility = new Compatibilities()
            {
                DeviceType = uploadDTO.DeviceType
            };

            //Add to Compatibilities
            Compatibilities tempTempCompatibility = _compatibilityRepository.AddEntityReturned(tempCompatibility);

            tempCompatibility = tempTempCompatibility;

            _playStoreDBContext.SaveChanges();
            //*****************************************************

            var tempPrice = new Prices()
            {
                Currency = uploadDTO.Currency,
                Value    = uploadDTO.Value
            };

            //Add to Prices
            Prices tempTempPrice = _priceRepository.AddEntityReturned(tempPrice);

            tempPrice = tempTempPrice;

            _playStoreDBContext.SaveChanges();
            //*****************************************************

            var tempUserApp = new UserApp()
            {
                UsersId = tempUser.Id,
                AppsId  = tempApp.Id
            };

            UserApp checkUserApp = _playStoreDBContext.UserApp.Where(x => x.UsersId == tempUserApp.UsersId && x.AppsId == tempUserApp.AppsId).FirstOrDefault();

            if (checkUserApp == null)
            {
                //Add to UserApp
                UserApp tempTempUserApp = _userAppRepository.AddEntityReturned(tempUserApp);

                //tempUserApp=tempTempUserApp;

                _playStoreDBContext.SaveChanges();
            }

            tempUserApp = _playStoreDBContext.UserApp.Where(x => x.UsersId == tempUserApp.UsersId && x.AppsId == tempUserApp.AppsId).FirstOrDefault();

            //*****************************************************

            var tempUploads = new Uploads()
            {
                UsersId   = tempUser.Id,
                UserAppId = tempUserApp.Id,
                Accepted  = uploadDTO.Accepted,
                Update    = uploadDTO.Update
            };

            //Add to Uploads
            Uploads tempTempUploads = _uploadRepository.AddEntityReturned(
                tempUploads
                );

            tempUploads = tempTempUploads;

            _playStoreDBContext.SaveChanges();
            //*****************************************************
        }
Beispiel #4
0
        //Adds a Downloads object
        public void AddDownload(DownloadDTO downloadDTO)
        {
            //*****************************************************

            var tempUser = new User()
            {
                Name    = downloadDTO.UserName,
                Surname = downloadDTO.UserSurname,
                Email   = downloadDTO.Email
            };

            //Add to Users
            User tempTempUser = _userRepository.AddEntityReturned(tempUser);

            tempUser = tempTempUser;
            //*****************************************************

            var tempApp = new App()
            {
                Name       = downloadDTO.AppName,
                Genre      = downloadDTO.Genre,
                LastUpdate = downloadDTO.LastUpdate,
                AppBrand   = downloadDTO.AppBrand
            };

            //Add to Apps
            App tempTempApp = _appRepository.AddEntityReturned(tempApp);

            //Updates the object of type Apps
            tempApp = tempTempApp;

            //*****************************************************

            var tempCompatibility = new Compatibilities()
            {
                DeviceType = downloadDTO.DeviceType
            };

            //Add to Compatibilities
            Compatibilities tempTempCompatibility = _compatibilityRepository.AddEntityReturned(tempCompatibility);

            tempCompatibility = tempTempCompatibility;

            //*****************************************************


            var tempPrice = new Prices()
            {
                Currency = downloadDTO.Currency,
                Value    = downloadDTO.Value
            };

            //Add to Prices
            Prices tempTempPrice = _priceRepository.AddEntityReturned(tempPrice);

            tempPrice = tempTempPrice;

            //*****************************************************

            var tempUserApp = new UserApp()
            {
                UsersId = tempUser.Id,
                AppsId  = tempApp.Id
            };

            //Add to UserApp
            UserApp tempTempUserApp = _userAppRepository.AddEntityReturned(tempUserApp);

            tempUserApp = tempTempUserApp;

            //*****************************************************

            var tempDownloads = new Downloads()
            {
                Successful = downloadDTO.Successful
            };

            //Add to Uploads
            Downloads tempTempUploads = _downloadRepository.AddEntityReturned(tempDownloads);

            tempDownloads = tempTempUploads;

            //*****************************************************
        }