Beispiel #1
0
        /// <summary>
        ///     Copy name from view model to database object model.
        /// </summary>
        /// <param name="data">Joined database object model</param>
        /// <param name="model"><see cref="OptionItem" /> instance</param>
        protected override void CopyModelToTrans(
            JoinedItem <hcc_ProductOptionsItems, hcc_ProductOptionItemTranslation> data, OptionItem model)
        {
            data.ItemTranslation.ProductOptionItemId = data.Item.bvin;

            data.ItemTranslation.Name = model.Name;
        }
Beispiel #2
0
        protected override void CopyModelToTrans(JoinedItem <hcc_ContentBlock, hcc_ContentBlockTranslation> data,
                                                 ContentBlock model)
        {
            data.ItemTranslation.ContentBlockId = data.Item.bvin;

            data.ItemTranslation.TextSettings = Json.ObjectToJson(model.TextSettings);
        }
Beispiel #3
0
        public virtual bool Create(V item, bool useModelCulture)
        {
            var result = false;

            var entity = new JoinedItem <T, TT>();

            using (var s = CreateStrategy())
            {
                CopyModelToItem(entity, item);
                s.Add(entity.Item);
                result = s.SubmitChanges();

                CopyModelToTrans(entity, item);
                UpdateTransCulture(entity.ItemTranslation, item as ILocalizableModel, useModelCulture);

                if (HasTranslation(entity.ItemTranslation))
                {
                    s.AddEntity(entity.ItemTranslation);
                    result &= s.SubmitChanges();
                }
            }

            CopyDataToModel(entity, item);
            MergeSubItems(item);

            return(result);
        }
        protected override void CopyModelToTrans(
            JoinedItem <hcc_ProductPropertyValue, hcc_ProductPropertyValueTranslation> data, ProductPropertyValue model)
        {
            data.ItemTranslation.ProductPropertyValueId = data.Item.Id;

            data.ItemTranslation.PropertyLocalizableValue = model.PropertyLocalizableValue;
        }
        protected override void CopyModelToTrans(JoinedItem <hcc_ProductType, hcc_ProductTypeTranslation> data,
                                                 ProductType model)
        {
            data.ItemTranslation.ProductTypeId = data.Item.bvin;

            data.ItemTranslation.ProductTypeName = model.ProductTypeName;
        }
Beispiel #6
0
        protected override void CopyModelToTrans(JoinedItem <hcc_ShippingMethod, hcc_ShippingMethodTranslation> data,
                                                 ShippingMethod model)
        {
            data.ItemTranslation.ShippingMethodId = data.Item.bvin;

            data.ItemTranslation.Name = model.Name;
        }
Beispiel #7
0
 protected override void CopyModelToItem(JoinedItem <hcc_Region, hcc_RegionTranslation> data, Region model)
 {
     data.Item.RegionId     = model.RegionId;
     data.Item.CountryId    = model.CountryId;
     data.Item.Abbreviation = model.Abbreviation;
     data.Item.SystemName   = model.SystemName;
 }
        protected override void CopyModelToTrans(JoinedItem <hcc_Promotions, hcc_PromotionTranslation> data,
                                                 Promotion model)
        {
            data.ItemTranslation.PromotionId = data.Item.Id;

            data.ItemTranslation.CustomerDescription = model.CustomerDescription;
        }
Beispiel #9
0
        protected override void CopyModelToTrans(
            JoinedItem <hcc_ProductPropertyChoice, hcc_ProductPropertyChoiceTranslation> data,
            ProductPropertyChoice model)
        {
            data.ItemTranslation.ProductPropertyChoiceId = data.Item.Id;

            data.ItemTranslation.DisplayName = model.DisplayName;
        }
        protected override void CopyModelToTrans(JoinedItem <hcc_ProductProperty, hcc_ProductPropertyTranslation> data,
                                                 ProductProperty model)
        {
            data.ItemTranslation.ProductPropertyId = data.Item.Id;

            data.ItemTranslation.DisplayName             = model.DisplayName;
            data.ItemTranslation.DefaultLocalizableValue = model.DefaultLocalizableValue;
        }
Beispiel #11
0
 protected override void CopyModelToItem(JoinedItem <hcc_StoreSettings, hcc_StoreSettingsTranslations> data,
                                         StoreSetting model)
 {
     data.Item.Id           = model.Id;
     data.Item.SettingName  = model.SettingName;
     data.Item.SettingValue = model.SettingValue;
     data.Item.StoreId      = model.StoreId;
 }
Beispiel #12
0
        /// <summary>
        ///     Copy view model name to database object model
        /// </summary>
        /// <param name="data">Joined item for database object model</param>
        /// <param name="model"><see cref="Option" /> instance</param>
        protected override void CopyModelToTrans(JoinedItem <hcc_ProductOptions, hcc_ProductOptionTranslation> data,
                                                 Option model)
        {
            data.ItemTranslation.ProductOptionId = data.Item.bvin;

            data.ItemTranslation.Name         = model.Name;
            data.ItemTranslation.TextSettings = model.TextSettings.ToJson();
        }
Beispiel #13
0
 protected virtual void CopyDataToModel(JoinedItem <T, TT> data, V model)
 {
     CopyItemToModel(data.Item, model);
     if (data.ItemTranslation != null)
     {
         CopyTransToModel(data.ItemTranslation, model);
     }
 }
Beispiel #14
0
        protected override void CopyModelToTrans(JoinedItem <hcc_StoreSettings, hcc_StoreSettingsTranslations> data,
                                                 StoreSetting model)
        {
            data.ItemTranslation.StoreSettingsId = data.Item.Id;

            data.ItemTranslation.Culture = model.ContentCulture;
            data.ItemTranslation.LocalizedSettingValue = model.LocalizedSettingValue;
        }
 protected override void CopyModelToItem(
     JoinedItem <hcc_ProductPropertyValue, hcc_ProductPropertyValueTranslation> data, ProductPropertyValue model)
 {
     data.Item.Id            = model.Id;
     data.Item.ProductBvin   = DataTypeHelper.BvinToGuid(model.ProductID);
     data.Item.PropertyId    = model.PropertyID;
     data.Item.StoreId       = model.StoreId;
     data.Item.PropertyValue = model.PropertyValue;
 }
 protected override void CopyModelToItem(JoinedItem <hcc_ProductType, hcc_ProductTypeTranslation> data,
                                         ProductType model)
 {
     data.Item.bvin         = DataTypeHelper.BvinToGuid(model.Bvin);
     data.Item.IsPermanent  = model.IsPermanent;
     data.Item.LastUpdated  = model.LastUpdated;
     data.Item.StoreId      = model.StoreId;
     data.Item.TemplateName = model.TemplateName;
 }
Beispiel #17
0
        protected override void CopyModelToTrans(JoinedItem <hcc_HtmlTemplates, hcc_HtmlTemplateTranslation> data,
                                                 HtmlTemplate model)
        {
            data.ItemTranslation.HtmlTemplateId = data.Item.Id;

            data.ItemTranslation.Subject          = model.Subject;
            data.ItemTranslation.Body             = model.Body;
            data.ItemTranslation.RepeatingSection = model.RepeatingSection;
        }
Beispiel #18
0
        public virtual bool BatchCreate(List <V> items, bool useModelCulture, bool mergeSubItems = true)
        {
            var result = false;

            if (items.Count == 0)
            {
                return(result);
            }

            var entities = new List <JoinedItem <T, TT> >();

            using (var s = CreateStrategy())
            {
                s.AutoDetectChanges(false);

                foreach (var item in items)
                {
                    var entity = new JoinedItem <T, TT>();
                    CopyModelToItem(entity, item);
                    entities.Add(entity);
                    s.Add(entity.Item);
                }
                result = s.SubmitChanges();

                for (var i = 0; i < items.Count; i++)
                {
                    var item   = items[i];
                    var entity = entities[i];
                    CopyModelToTrans(entity, item);
                    UpdateTransCulture(entity.ItemTranslation, item as ILocalizableModel, useModelCulture);

                    if (HasTranslation(entity.ItemTranslation))
                    {
                        s.AddEntity(entity.ItemTranslation);
                    }
                }
                result &= s.SubmitChanges();
            }

            for (var i = 0; i < items.Count; i++)
            {
                var item   = items[i];
                var entity = entities[i];
                CopyDataToModel(entity, item);
            }

            if (mergeSubItems)
            {
                foreach (var item in items)
                {
                    MergeSubItems(item);
                }
            }

            return(result);
        }
Beispiel #19
0
 protected override void CopyModelToItem(JoinedItem <hcc_HtmlTemplates, hcc_HtmlTemplateTranslation> data,
                                         HtmlTemplate model)
 {
     data.Item.Id             = model.Id;
     data.Item.StoreId        = model.StoreId;
     data.Item.LastUpdatedUtc = model.LastUpdatedUtc;
     data.Item.DisplayName    = model.DisplayName;
     data.Item.FromEmail      = model.From;
     data.Item.TemplateType   = (int)model.TemplateType;
 }
 protected override void CopyModelToItem(JoinedItem <hcc_Country, hcc_CountryTranslation> data, Country model)
 {
     data.Item.CountryId   = DataTypeHelper.BvinToGuid(model.Bvin);
     data.Item.CultureCode = model.CultureCode;
     data.Item.SystemName  = model.SystemName;
     data.Item.IsoCode     = model.IsoCode;
     data.Item.IsoAlpha3   = model.IsoAlpha3;
     data.Item.IsoNumeric  = model.IsoNumeric;
     data.Item.PostalCodeValidationRegex = model.PostalCodeValidationRegex;
 }
Beispiel #21
0
 protected override void CopyModelToItem(
     JoinedItem <hcc_ProductPropertyChoice, hcc_ProductPropertyChoiceTranslation> data,
     ProductPropertyChoice model)
 {
     data.Item.ChoiceName  = model.ChoiceName;
     data.Item.Id          = model.Id;
     data.Item.LastUpdated = model.LastUpdated;
     data.Item.PropertyId  = model.PropertyId;
     data.Item.SortOrder   = model.SortOrder;
     data.Item.StoreId     = model.StoreId;
 }
        protected override void CopyModelToTrans(JoinedItem <hcc_Category, hcc_CategoryTranslation> data, Category model)
        {
            data.ItemTranslation.CategoryId = data.Item.bvin;

            data.ItemTranslation.Name            = model.Name;
            data.ItemTranslation.Description     = model.Description;
            data.ItemTranslation.Keywords        = model.Keywords;
            data.ItemTranslation.MetaDescription = model.MetaDescription;
            data.ItemTranslation.MetaKeywords    = model.MetaKeywords;
            data.ItemTranslation.MetaTitle       = model.MetaTitle;
        }
Beispiel #23
0
 protected override void CopyModelToItem(JoinedItem <hcc_ContentBlock, hcc_ContentBlockTranslation> data,
                                         ContentBlock model)
 {
     data.Item.bvin               = DataTypeHelper.BvinToGuid(model.Bvin);
     data.Item.StoreId            = model.StoreId;
     data.Item.LastUpdated        = model.LastUpdated;
     data.Item.ColumnID           = DataTypeHelper.BvinToGuid(model.ColumnId);
     data.Item.ControlName        = model.ControlName;
     data.Item.SortOrder          = model.SortOrder;
     data.Item.SerializedSettings = Json.ObjectToJson(model.BaseSettings);
     data.Item.SerializedLists    = Json.ObjectToJson(model.Lists);
 }
Beispiel #24
0
 /// <summary>
 ///     Copy data from view model to database object model.
 /// </summary>
 /// <param name="data">Joined database object model</param>
 /// <param name="model"><see cref="OptionItem" /> instance</param>
 protected override void CopyModelToItem(
     JoinedItem <hcc_ProductOptionsItems, hcc_ProductOptionItemTranslation> data, OptionItem model)
 {
     data.Item.bvin             = DataTypeHelper.BvinToGuid(model.Bvin);
     data.Item.IsLabel          = model.IsLabel;
     data.Item.OptionBvin       = DataTypeHelper.BvinToGuid(model.OptionBvin);
     data.Item.PriceAdjustment  = model.PriceAdjustment;
     data.Item.SortOrder        = model.SortOrder;
     data.Item.StoreId          = model.StoreId;
     data.Item.WeightAdjustment = model.WeightAdjustment;
     data.Item.IsDefault        = model.IsDefault;
 }
Beispiel #25
0
 /// <summary>
 ///     Copy viewer model to database object model
 /// </summary>
 /// <param name="data">Joined item for database object model</param>
 /// <param name="model"><see cref="Option" /> instance</param>
 protected override void CopyModelToItem(JoinedItem <hcc_ProductOptions, hcc_ProductOptionTranslation> data,
                                         Option model)
 {
     data.Item.bvin          = DataTypeHelper.BvinToGuid(model.Bvin);
     data.Item.IsShared      = model.IsShared;
     data.Item.IsVariant     = model.IsVariant;
     data.Item.OptionType    = (int)model.OptionType;
     data.Item.NameIsHidden  = model.NameIsHidden;
     data.Item.Settings      = model.Settings.ToJson();
     data.Item.StoreId       = model.StoreId;
     data.Item.IsColorSwatch = model.IsColorSwatch;
 }
Beispiel #26
0
        protected virtual V FirstPoco(JoinedItem <T, TT> item)
        {
            if (item == null)
            {
                return(null);
            }

            var model = new V();

            CopyDataToModel(item, model);
            GetSubItems(model);
            return(model);
        }
Beispiel #27
0
 protected override void CopyModelToItem(JoinedItem <hcc_ShippingMethod, hcc_ShippingMethodTranslation> data,
                                         ShippingMethod model)
 {
     data.Item.Adjustment         = model.Adjustment;
     data.Item.AdjustmentType     = (int)model.AdjustmentType;
     data.Item.bvin               = DataTypeHelper.BvinToGuid(model.Bvin);
     data.Item.LastUpdated        = model.LastUpdated;
     data.Item.Settings           = Json.ObjectToJson(model.Settings);
     data.Item.ShippingProviderId = model.ShippingProviderId;
     data.Item.StoreId            = model.StoreId;
     data.Item.ZoneId             = model.ZoneId;
     data.Item.VisibilityMode     = (int)model.VisibilityMode;
     data.Item.VisibilityAmount   = model.VisibilityAmount;
     data.Item.SortOrder          = model.SortOrder;
 }
 protected override void CopyModelToItem(JoinedItem <hcc_ProductProperty, hcc_ProductPropertyTranslation> data,
                                         ProductProperty model)
 {
     data.Item.CultureCode          = model.CultureCode;
     data.Item.DefaultValue         = model.DefaultValue;
     data.Item.DisplayOnSite        = model.DisplayOnSite ? 1 : 0;
     data.Item.DisplayToDropShipper = model.DisplayToDropShipper ? 1 : 0;
     data.Item.DisplayOnSearch      = model.DisplayOnSearch;
     data.Item.Id            = model.Id;
     data.Item.PropertyName  = model.PropertyName;
     data.Item.StoreId       = model.StoreId;
     data.Item.TypeCode      = (int)model.TypeCode;
     data.Item.LastUpdated   = model.LastUpdatedUtc;
     data.Item.IsLocalizable = model.IsLocalizable;
 }
Beispiel #29
0
 protected override void CopyModelToItem(JoinedItem <hcc_Product, hcc_ProductTranslation> data, Product model)
 {
     data.Item.AllowReviews        = model.AllowReviews;
     data.Item.bvin                = DataTypeHelper.BvinToGuid(model.Bvin);
     data.Item.CreationDate        = model.CreationDateUtc;
     data.Item.CustomProperties    = model.CustomPropertiesToXml();
     data.Item.Featured            = model.Featured;
     data.Item.IsSearchable        = model.IsSearchable;
     data.Item.GiftWrapAllowed     = model.GiftWrapAllowed ? 1 : 0;
     data.Item.GiftWrapPrice       = model.GiftWrapPrice;
     data.Item.ImageFileMedium     = model.ImageFileMedium;
     data.Item.ImageFileSmall      = model.ImageFileSmall;
     data.Item.OutOfStockMode      = (int)model.InventoryMode;
     data.Item.IsAvailableForSale  = model.IsAvailableForSale;
     data.Item.IsUserPrice         = model.IsUserSuppliedPrice;
     data.Item.HideQty             = model.HideQty;
     data.Item.LastUpdated         = model.LastUpdated;
     data.Item.ListPrice           = model.ListPrice;
     data.Item.ManufacturerID      = DataTypeHelper.BvinToNullableGuid(model.ManufacturerId);
     data.Item.MinimumQty          = model.MinimumQty;
     data.Item.PostContentColumnId = model.PostContentColumnId;
     data.Item.PreContentColumnId  = model.PreContentColumnId;
     data.Item.ProductTypeId       = DataTypeHelper.BvinToNullableGuid(model.ProductTypeId);
     data.Item.ExtraShipFee        = model.ShippingDetails.ExtraShipFee;
     data.Item.ShippingHeight      = model.ShippingDetails.Height;
     data.Item.NonShipping         = model.ShippingDetails.IsNonShipping ? 1 : 0;
     data.Item.ShippingLength      = model.ShippingDetails.Length;
     data.Item.ShippingWeight      = model.ShippingDetails.Weight;
     data.Item.ShippingWidth       = model.ShippingDetails.Width;
     data.Item.ShipSeparately      = model.ShippingDetails.ShipSeparately ? 1 : 0;
     data.Item.ShippingMode        = (int)model.ShippingMode;
     data.Item.SiteCost            = model.SiteCost;
     data.Item.SitePrice           = model.SitePrice;
     data.Item.SKU                   = model.Sku;
     data.Item.Status                = (int)model.Status;
     data.Item.StoreId               = model.StoreId;
     data.Item.TaxExempt             = model.TaxExempt ? 1 : 0;
     data.Item.TaxClass              = model.TaxSchedule.ToString();
     data.Item.TemplateName          = model.TemplateName;
     data.Item.RewriteUrl            = model.UrlSlug;
     data.Item.VendorID              = DataTypeHelper.BvinToNullableGuid(model.VendorId);
     data.Item.IsBundle              = model.IsBundle;
     data.Item.IsGiftCard            = model.IsGiftCard;
     data.Item.IsRecurring           = model.IsRecurring;
     data.Item.RecurringInterval     = model.RecurringInterval;
     data.Item.RecurringIntervalType = (int)model.RecurringIntervalType;
     data.Item.ShippingCharge        = (int)model.ShippingCharge;
 }
 protected override void CopyModelToItem(JoinedItem <hcc_Promotions, hcc_PromotionTranslation> data,
                                         Promotion model)
 {
     data.Item.Id                = model.Id;
     data.Item.StoreId           = model.StoreId;
     data.Item.Mode              = (int)model.Mode;
     data.Item.LastUpdatedUtc    = model.LastUpdatedUtc;
     data.Item.Name              = model.Name;
     data.Item.StartDateUtc      = model.StartDateUtc;
     data.Item.EndDateUtc        = model.EndDateUtc;
     data.Item.IsEnabled         = model.IsEnabled;
     data.Item.ActionsXml        = model.ActionsToXml();
     data.Item.QualificationsXml = model.QualificationsToXml();
     data.Item.DoNotCombine      = model.DoNotCombine;
     data.Item.SortOrder         = model.SortOrder;
 }