示例#1
0
 protected virtual void UpdateValueLocales(TaskAttributeValue taskAttributeValue, TaskAttributeValueModel model)
 {
     foreach (var localized in model.Locales)
     {
         _localizedEntityService.SaveLocalizedValue(taskAttributeValue,
                                                    x => x.Name,
                                                    localized.Name,
                                                    localized.LanguageId);
     }
 }
        public virtual void DeleteTaskAttributeValue(TaskAttributeValue taskAttributeValue)
        {
            if (taskAttributeValue == null)
            {
                throw new ArgumentNullException(nameof(taskAttributeValue));
            }

            _taskAttributeValueRepository.Delete(taskAttributeValue);

            _cacheManager.RemoveByPattern(GSTaskServiceDefaults.TaskAttributesPatternCacheKey);
            _cacheManager.RemoveByPattern(GSTaskServiceDefaults.TaskAttributeValuesPatternCacheKey);

            //event notification
            _eventPublisher.EntityDeleted(taskAttributeValue);
        }
        public virtual TaskAttributeValueModel PrepareTaskAttributeValueModel(TaskAttributeValueModel model,
                                                                              TaskAttribute taskAttribute, TaskAttributeValue taskAttributeValue, bool excludeProperties = false)
        {
            if (taskAttribute == null)
            {
                throw new ArgumentNullException(nameof(taskAttribute));
            }

            Action <TaskAttributeValueLocalizedModel, int> localizedModelConfiguration = null;

            if (taskAttributeValue != null)
            {
                //fill in model values from the entity
                model = model ?? taskAttributeValue.ToModel <TaskAttributeValueModel>();

                //define localized model configuration action
                localizedModelConfiguration = (locale, languageId) =>
                {
                    locale.Name = _localizationService.GetLocalized(taskAttributeValue, entity => entity.Name, languageId, false, false);
                };
            }

            model.TaskAttributeId = taskAttribute.Id;

            if (!excludeProperties)
            {
                model.Locales = _localizedModelFactory.PrepareLocalizedModels(localizedModelConfiguration);
            }

            return(model);
        }