public static void Initial(AppDBContent content) { if (!content.Category.Any()) { content.Category.AddRange(Categories.Select(c => c.Value)); } if (!content.Product.Any()) { content.Product.AddRange(Products.Select(c => c.Value)); } if (!content.Compatibility.Any()) { content.Compatibility.AddRange(Compatibilities.Select(c => c.Value)); } content.SaveChanges(); /*if (!content.ProductsCompatibility.Any()) { * content.ProductsCompatibility.AddRange(ProductsCompatibilities.Select(c => c)); * } * * content.SaveChanges();*/ }
public Model(int width, int height, Dictionary <int, int> weight, Compatibilities compatibilities) { this.width = width; this.height = height; this.weight = weight; this.compatibilities = compatibilities; wavefuntion = new WaveFuntion(width, height, weight); }
public void Increase(Compatibilities compt) { if (type != compt.type) { return; } ababo[0] += compt.ababo[0]; ababo[1] += compt.ababo[1]; ababo[2] += compt.ababo[2]; ababo[3] += compt.ababo[3]; }
/// <summary>What can he get in place</summary> /// <returns></returns> public Compatibilities Compatibility() { Compatibilities compt = new Compatibilities(BloodType.None, 0, 0, 0, 0); if (type == BloodType.Blood || type == BloodType.Platelet) { switch (family) { case BloodFamily.A: compt = new Compatibilities(type, 1, 0, 0, 1); break; case BloodFamily.B: compt = new Compatibilities(type, 0, 1, 0, 1); break; case BloodFamily.AB: compt = new Compatibilities(type, 1, 1, 1, 1); break; case BloodFamily.O: compt = new Compatibilities(type, 0, 0, 0, 1); break; } } else if (type == BloodType.Plasma) { switch (family) { case BloodFamily.A: compt = new Compatibilities(type, 1, 0, 1, 0); break; case BloodFamily.B: compt = new Compatibilities(type, 0, 1, 1, 0); break; case BloodFamily.AB: compt = new Compatibilities(type, 0, 0, 1, 0); break; case BloodFamily.O: compt = new Compatibilities(type, 1, 1, 1, 1); break; } } return(compt); }
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(); //***************************************************** }
//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; //***************************************************** }