Beispiel #1
0
 public SKUEditViewItem(Model.SKU sku)
     : base(sku)
 {
     SelectedFeatureGUIDs = new List <Guid>(
         sku.SkuFeatures.Select(x => x.FeatureId)
         );
 }
Beispiel #2
0
 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, ", ");
 }
Beispiel #3
0
        /// <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);
        }
Beispiel #4
0
 /// <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;
 }
Beispiel #5
0
        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));
        }
Beispiel #6
0
        /// <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);
        }
Beispiel #7
0
 public SKUCreateViewItem(Model.SKU sku)
     : base(sku)
 {
     SelectedFeatureGUIDs = new List <Guid>();
 }
Beispiel #8
0
 /// <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));
 }
Beispiel #9
0
        /// <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());
        }
Beispiel #10
0
 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;
 }
Beispiel #11
0
 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, ", ");
 }