Ejemplo 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);
        }
Ejemplo n.º 2
0
 public async Task <FilterDetailsDto> PutFilter(int id, FilterUpdateDto createDto)
 {
     createDto = createDto ?? new FilterUpdateDto();
     return(await _appService.Update(id, createDto));
 }