Exemplo n.º 1
0
        private void SetCustomerLanguage(int languageId, int storeId)
        {
            var objAttribute = new Domain.Entities.Data.GenericAttribute
            {
                EntityId    = CurrentCustomer.Id,
                KeyGroup    = "Customer",
                Key         = "LanguageId",
                Value       = languageId.ToString(),
                StoreId     = storeId,
                CreatedDate = DateTime.Now,
                UpdatedDate = DateTime.Now
            };

            var attribute = _genericAttributeService.GetByKey(objAttribute.EntityId
                                                              , objAttribute.KeyGroup, objAttribute.Key);

            if (attribute == null)
            {
                _genericAttributeService.Create(objAttribute);
            }
            else
            {
                attribute.Value = languageId.ToString();
                _genericAttributeService.Update(attribute);
            }
        }
        public static string GetAttribute(this Customer entity, string keyGroup, string key, IGenericAttributeService genericAttributeService, int storeId = 0)
        {
            if (genericAttributeService == null)
            {
                genericAttributeService = DependencyResolver.Current.GetService <IGenericAttributeService>();
            }

            var prop = genericAttributeService.GetByKey(entity.Id, keyGroup, key);

            return(prop?.Value);
        }