Esempio n. 1
0
        public async Task <FilterDetailsDto> Update(int id, FilterUpdateDto updateDto)
        {
            var updateFilter = _domainService.Find(id);

            if (updateFilter == null)
            {
                throw SocialExceptions.FilterNotExists(id);
            }
            if (updateDto.IfPublic == false && updateFilter.IfPublic == true)
            {
                updateFilter.CreatedBy = UserContext.UserId;
            }
            _domainService.DeleteConditons(updateFilter);
            Mapper.Map(updateDto, updateFilter);
            _domainService.UpdateFilter(updateFilter, Mapper.Map <List <FilterConditionCreateDto>, List <FilterCondition> >(updateDto.Conditions.ToList()).ToArray());
            using (var uow = UnitOfWorkManager.Begin(TransactionScopeOption.RequiresNew))
            {
                CurrentUnitOfWork.SaveChanges();
                uow.Complete();
            }
            await _notificationManager.NotifyUpdateFilter(updateFilter.SiteId, updateFilter.Id);

            var filterDto = Mapper.Map <FilterDetailsDto>(updateFilter);
            List <FilterDetailsDto> filterDtos = new List <FilterDetailsDto>();

            filterDtos.Add(filterDto);
            _agentService.FillCreatedByName(filterDtos);
            return(filterDto);
        }
Esempio n. 2
0
        public bool HasConversation(int filterId, int conversationId)
        {
            var filter = _domainService.Find(filterId);

            if (filter == null)
            {
                throw SocialExceptions.FilterNotExists(filterId);
            }
            return(_domainService.HasConversation(filter, conversationId));
        }
Esempio n. 3
0
        public async Task Delete(int id)
        {
            var filter = _domainService.Find(id);

            if (filter == null)
            {
                throw SocialExceptions.FilterNotExists(id);
            }
            _domainService.Delete(id);
            await _notificationManager.NotifyDeleteFilter(filter.SiteId, filter.Id);
        }
Esempio n. 4
0
        public FilterDetailsDto Find(int id)
        {
            var filter = _domainService.Find(id);

            if (filter == null)
            {
                throw SocialExceptions.FilterNotExists(id);
            }
            var filterDto = Mapper.Map <FilterDetailsDto>(filter);

            filterDto.CreatedByName = _agentService.GetDisplayName(filterDto.CreatedBy);
            return(filterDto);
        }
Esempio n. 5
0
        public FilterListDto FindSummary(int id)
        {
            var filter = _domainService.Find(id);

            if (filter == null)
            {
                throw SocialExceptions.FilterNotExists(id);
            }

            var dto = Mapper.Map <FilterListDto>(filter);

            dto.ConversationNum = _domainService.GetConversationNum(filter);
            dto.CreatedByName   = _agentService.GetDisplayName(dto.CreatedBy);

            return(dto);
        }