Example #1
0
        /// <summary>
        /// 自定义检查通知公告输入逻辑错误
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <CustomerModelStateValidationDto> CheckErrorAsync(AnnouncementForEdit input)
        {
            //TODO: 自定义逻辑判断是否有逻辑错误

            return(new CustomerModelStateValidationDto()
            {
                HasModelError = false
            });
        }
Example #2
0
        public async Task <ActionResult> Create(AnnouncementForEdit announcementDto)
        {
            if (!CheckModelState(await _announcementAppService.CheckErrorAsync(announcementDto)))
            {
                return(View(announcementDto));
            }
            await _announcementAppService.CreateOrUpdateAsync(announcementDto);

            return(RedirectToAction("Index"));
        }
Example #3
0
 public async Task CreateOrUpdateAsync(AnnouncementForEdit input)
 {
     if (input.AnnouncementEditDto.Id.HasValue)
     {
         await UpdateAsync(input);
     }
     else
     {
         await CreateAsync(input);
     }
 }
Example #4
0
        public async Task UpdateAsync(AnnouncementForEdit input)
        {
            //TODO: 更新前的逻辑判断,是否允许更新

            await _announcementUserRepository.DeleteAsync(p => p.AnnouncementId == input.AnnouncementEditDto.Id.Value);

            var entity = await _announcementRepository.GetAsync(input.AnnouncementEditDto.Id.Value);

            input.AnnouncementEditDto.MapTo(entity);
            await _announcementRepository.UpdateAsync(entity);

            await _notificationManager.SendMessageAsync(
                input.AnnouncementEditDto.AnnouncementUsers.Select(p => new UserIdentifier(AbpSession.TenantId, p.UserId))
                .ToArray(), PlatformConsts.NotificationConstNames.Announcement_Send, entity.Title, new
            {
                Title        = entity.Title,
                CreationTime = entity.CreationTime
            });
        }
Example #5
0
        public async Task <AnnouncementForEdit> CreateAsync(AnnouncementForEdit input)
        {
            //TODO: 新增前的逻辑判断,是否允许新增

            var entity = input.AnnouncementEditDto.MapTo <Announcement>();

            entity = await _announcementRepository.InsertAsync(entity);

            await _notificationManager.SendMessageAsync(
                input.AnnouncementEditDto.AnnouncementUsers.Select(p => new UserIdentifier(AbpSession.TenantId, p.UserId))
                .ToArray(), PlatformConsts.NotificationConstNames.Announcement_Send, entity.Title, new
            {
                Title        = entity.Title,
                CreationTime = entity.CreationTime
            });

            return(new AnnouncementForEdit {
                AnnouncementEditDto = entity.MapTo <AnnouncementEditDto>()
            });
        }