public SKUEditViewItem(Model.SKU sku) : base(sku) { SelectedFeatureGUIDs = new List <Guid>( sku.SkuFeatures.Select(x => x.FeatureId) ); }
public SKUIndexViewItem(Model.SKU sku, Model.Vendor vendor, Model.PrivateKey privateKey, IEnumerable <Model.SkuFeature> skuFeatures) : base(sku) { VendorName = vendor.Name; PrivateKeyName = privateKey.DisplayName; FeatureSummary = skuFeatures.ToSummary(x => x.Feature.FeatureName, 3, ", "); }
/// <summary> /// Construct the viewmodel /// </summary> /// <param name="sku">SKU entity</param> /// <param name="vendors">List of vendors to select</param> /// <param name="privateKeys">List of privateKeys to select</param> /// <param name="features">List of features to select</param> public SKUEditViewModel(Model.SKU sku, List <Model.Vendor> vendors, List <Model.PrivateKey> privateKeys, List <Model.Feature> features) { SKU = new SKUEditViewItem(sku); VendorList = vendors.ToSelectList(x => x.ObjectId, x => x.Name); PrivateKeyList = privateKeys.ToSelectList(x => x.PrivateKeyId, x => x.DisplayName); FeatureList = features.ToMultiSelectList(x => x.FeatureId, x => x.FeatureName); }
/// <summary> /// Construct viewmodel /// </summary> /// <param name="sku">SKU that this viewmodel represents</param> public SKUViewModel(Model.SKU sku) : this() { //Load properties into viewmodel SkuId = sku.SkuId; VendorId = sku.VendorId; PrivateKeyId = sku.PrivateKeyId; SkuCode = sku.SkuCode; SkuAlternateString = sku.SkuAternativeCode; MaxDomains = sku.MaxDomains; EditOwnershipDuration = sku.EditOwnershipDuration; MaxSupportContacts = sku.MaxSupportContacts; EditSupportContactsDuration = sku.EditSupportContactsDuration; LicenseDuration = sku.LicenseDuration; AutoDomainDuration = sku.AutoDomainDuration; ManualDomainDuration = sku.ManualDomainDuration; CanDeleteAutoDomains = sku.CanDeleteAutoDomains; CanDeleteManualDomains = sku.CanDeleteManualDomains; ReleaseDate = sku.ReleaseDate; ExpirationDate = sku.ExpirationDate; }
public ActionResult Edit(SKUEditViewModel viewModel) { if (ModelState.IsValid) { using (var context = dataContextFactory.CreateByUser()) { Model.SKU sku = (from x in context.SKUs where x.SkuId == viewModel.SKU.SkuId select x).FirstOrDefault(); viewModel.ToEntity(sku); //Offload adding and removing SKUFeatures to Dynamic SKU Model sku.AddFeatures(viewModel.GetNewFeatureGUIDs(sku)); sku.RemoveFeatures(viewModel.GetRemovedFeatureGUIDs(sku)); if (context.SaveChanges(CreateValidationFailed)) { return(RedirectToAction("Index")); } } } return(Edit(viewModel.SKU.SkuId)); }
/// <summary> /// Convert back to SKU instance /// </summary> /// <param name="original">Original SKU. If Null a new instance is created.</param> /// <returns>SKU containing viewmodel data </returns> public Model.SKU ToEntity(Model.SKU original) { Model.SKU current = original ?? new Model.SKU(); //Load properties into entity current.SkuId = this.SkuId; current.VendorId = this.VendorId; current.PrivateKeyId = this.PrivateKeyId; current.SkuCode = this.SkuCode; current.SkuAternativeCode = this.SkuAlternateString; current.MaxDomains = this.MaxDomains; current.EditOwnershipDuration = this.EditOwnershipDuration; current.MaxSupportContacts = this.MaxSupportContacts; current.EditSupportContactsDuration = this.EditSupportContactsDuration; current.LicenseDuration = this.LicenseDuration; current.AutoDomainDuration = this.AutoDomainDuration; current.ManualDomainDuration = this.ManualDomainDuration; current.CanDeleteAutoDomains = this.CanDeleteAutoDomains; current.CanDeleteManualDomains = this.CanDeleteManualDomains; current.ReleaseDate = this.ReleaseDate; current.ExpirationDate = this.ExpirationDate; return(current); }
public SKUCreateViewItem(Model.SKU sku) : base(sku) { SelectedFeatureGUIDs = new List <Guid>(); }
/// <summary> /// Convert back to SKU instance /// </summary> /// <param name="original">Original SKU. If Null a new instance is created.</param> /// <returns>SKU containing viewmodel data </returns> public Model.SKU ToEntity(Model.SKU original) { return(SKU.ToEntity(null)); }
/// <summary> /// Retrieve a list of removed features for this SKU /// </summary> /// <param name="original">Original SKU</param> /// <returns>List of removed feature Guids</returns> public List <Guid> GetRemovedFeatureGUIDs(Model.SKU original) { var originalFeatures = (from x in original.SkuFeatures select x.FeatureId); return(originalFeatures.Except(SKU.SelectedFeatureGUIDs).ToList()); }
public LicenseDetailsViewItem(Model.License license, Model.Customer purchasingCustomer, Model.Customer owningCustomer, Model.SKU sku) : base(license) { OwningCustomerName = (owningCustomer != null) ? owningCustomer.Name : "Not owned"; PurchasingCustomerName = purchasingCustomer.Name; SKUName = sku.SkuCode; }
public LicenseIndexViewItem(Model.License license, Model.Customer owningCustomer, Model.SKU sku, IEnumerable <Model.DomainLicense> domains) : base(license) { OwningCustomerName = (owningCustomer != null) ? owningCustomer.Name : "Not owned"; SKUName = sku.SkuCode; DomainSummary = domains.ToSummary(x => x.DomainName, 1, ", "); }