Esempio n. 1
0
        public bool Update(Domain.QueryView entity)
        {
            var original = _queryViewRepository.FindById(entity.QueryViewId);

            entity.ModifiedBy = _currentUser.SystemUserId;
            entity.ModifiedOn = DateTime.Now;
            var result = true;

            using (UnitOfWork.Build(_queryViewRepository.DbContext))
            {
                result = _queryViewRepository.Update(entity);
                _dependencyService.Update(entity);
                //localization
                _localizedLabelService.Update(entity.Name.IfEmpty(""), "LocalizedName", entity.QueryViewId, _appContext.BaseLanguage);
                _localizedLabelService.Update(entity.Description.IfEmpty(""), "Description", entity.QueryViewId, _appContext.BaseLanguage);
                //assigning roles
                if (original.AuthorizationEnabled || !entity.AuthorizationEnabled)
                {
                    _eventPublisher.Publish(new AuthorizationStateChangedEvent
                    {
                        ObjectId = new List <Guid> {
                            entity.QueryViewId
                        }
                        ,
                        State = false
                        ,
                        ResourceName = QueryViewDefaults.ModuleName
                    });
                }
                //set to cache
                _cacheService.SetEntity(entity);
            }
            return(result);
        }
Esempio n. 2
0
        public Domain.QueryView FindById(Guid id)
        {
            var dic = new Dictionary <string, string>();

            dic.Add("QueryViewId", id.ToString());
            Domain.QueryView entity = _cacheService.Get(dic, () =>
            {
                return(_queryViewRepository.FindById(id));
            });
            if (entity != null)
            {
                WrapLocalizedLabel(entity);
            }
            return(entity);
        }