public IQueryable <Model.Service> InsertService(Model.Service service) { int newId; //using (ScutexEntities db1 = new ScutexEntities()) //{ Service serv = new Service(); Mapper.CreateMap <Model.Service, Service>(); serv = Mapper.Map <Model.Service, Service>(service); serv.InboundPrivateKey = service.InboundKeyPair.PrivateKey; serv.InboundPublicKey = service.InboundKeyPair.PublicKey; serv.OutboundPrivateKey = service.OutboundKeyPair.PrivateKey; serv.OutboundPublicKey = service.OutboundKeyPair.PublicKey; serv.ManagementInboundPrivateKey = service.ManagementInboundKeyPair.PrivateKey; serv.ManagementInboundPublicKey = service.ManagementInboundKeyPair.PublicKey; serv.ManagementOutboundPrivateKey = service.ManagementOutboundKeyPair.PrivateKey; serv.ManagementOutboundPublicKey = service.ManagementOutboundKeyPair.PublicKey; db.AddToServices(serv); db.SaveChanges(); newId = serv.ServiceId; //} return(GetServiceById(newId)); }
public IQueryable <Model.Product> InsertProduct(Model.Product product) { int newId; //using (ScutexEntities db1 = new ScutexEntities()) //{ Product prod = new Product(); Mapper.CreateMap <Model.Product, Product>().ForMember(dest => dest.Features, opt => opt.Ignore());; prod = Mapper.Map <Model.Product, Product>(product); db.AddToProducts(prod); db.SaveChanges(); newId = prod.ProductId; //} return(GetProductById(newId)); }
public IQueryable <Model.Feature> InsertFeature(Model.Feature feature) { int newId; //using (ScutexEntities db1 = new ScutexEntities()) //{ Feature feat = new Feature(); Mapper.CreateMap <Model.Feature, Feature>(); feat = Mapper.Map <Model.Feature, Feature>(feature); db.AddToFeatures(feat); db.SaveChanges(); newId = feat.FeatureId; //} return(GetFeatureById(newId)); }
public IQueryable <LicenseTrialSettings> InsertTrialSettings(LicenseTrialSettings trialSettings) { int newId; //using (ScutexEntities db1 = new ScutexEntities()) //{ TrialSetting ts = new TrialSetting(); Mapper.CreateMap <Model.LicenseTrialSettings, TrialSetting>(); ts = Mapper.Map <Model.LicenseTrialSettings, TrialSetting>(trialSettings); ts.TrialExpirationOptionId = (int)trialSettings.ExpirationOptions; db.AddToTrialSettings(ts); db.SaveChanges(); newId = ts.TrialSettingId; //} return(GetTrialSettingsById(newId)); }
public IQueryable <Model.LicenseSet> InsertLicenseSet(Model.LicenseSet licenseSet) { int newId; //using (ScutexEntities db1 = new ScutexEntities()) //{ LicenseSet ls = new LicenseSet(); Mapper.CreateMap <Model.LicenseSet, LicenseSet>(); ls = Mapper.Map <Model.LicenseSet, LicenseSet>(licenseSet); ls.LicenseType = (int)licenseSet.SupportedLicenseTypes; db.AddToLicenseSets(ls); db.SaveChanges(); newId = ls.LicenseSetId; //} CreateLicsenSetFeatures(newId, licenseSet.Features); return(GetLicenseSetById(newId)); }
public void InsertLicenseKey(Model.LicenseKey key) { long newId; //using (ScutexEntities db1 = new ScutexEntities()) //{ LicenseKey lk = new LicenseKey(); Mapper.CreateMap <Model.LicenseKey, LicenseKey>(); lk = Mapper.Map <Model.LicenseKey, LicenseKey>(key); lk.LicenseKey1 = key.Key; lk.HashedLicenseKey = key.HashedLicenseKey; db.AddToLicenseKeys(lk); db.SaveChanges(); newId = lk.LicenseKeyId; //} }
public IQueryable <Model.License> InsertLicense(Model.License license) { int newId = 0; using (TransactionScope scope = new TransactionScope()) { //using (ScutexEntities db1 = new ScutexEntities()) //{ License l = new License(); //Mapper.CreateMap<Model.License, License>(); //l = Mapper.Map<Model.License, License>(license); l.Name = license.Name; l.BuyNowUrl = license.BuyNowUrl; l.ProductUrl = license.ProductUrl; l.EulaUrl = license.EulaUrl; l.SupportEmail = license.SupportEmail; l.SalesEmail = license.SalesEmail; l.KeyGeneratorTypeId = (int)license.KeyGeneratorType; l.CreatedOn = license.CreatedOn; if (license.UpdatedOn.HasValue) { l.UpdatedOn = license.UpdatedOn; } if (license.Service != null) { l.ServiceId = license.Service.ServiceId; } l.UniqueId = license.UniqueId; l.ProductId = license.Product.ProductId; l.PrivateKey = license.KeyPair.PrivateKey; l.PublicKey = license.KeyPair.PublicKey; if (license.TrailNotificationSettings != null) { l.TrialTryButtonDelay = license.TrailNotificationSettings.TryButtonDelay; } db.AddToLicenses(l); db.SaveChanges(); newId = l.LicenseId; //} foreach (var ls in license.LicenseSets) { ls.LicenseId = newId; _licenseSetsRepository.InsertLicenseSet(ls); } license.TrialSettings.LicenseId = newId; _trialSettingsRepository.InsertTrialSettings(license.TrialSettings); scope.Complete(); } return(GetLicenseById(newId)); }