Beispiel #1
0
        public virtual int AddNotice(NoticeInputDto noticeInputDto)
        {
            var notice = _mapper.Map <EmsTrainNotice>(noticeInputDto);

            _defaultDbContext.EmsTrainNotices.Add(notice);

            return(_defaultDbContext.SaveChanges());
        }
        public async Task <AjaxResult> Add(NoticeInputDto dto)
        {
            return(await AjaxResult.Business(async result =>
            {
                Check.NotNull(dto, nameof(dto));
                dto.Id = Guid.NewGuid();
                if (!ModelState.IsValid)
                {
                    result.Error("提交信息验证失败");
                    return;
                }

                dto.DateTime = DateTime.Now;
                await _noticeClientContract.AddNoticeAsync(dto);
                result.Type = AjaxResultType.Success;
            }));
        }
        public async Task AddNoticeAsync(NoticeInputDto dto)
        {
            var notice = dto.MapTo <Notice>();
            await _noticeRepo.InsertAsync(notice);

            var userIds = await _userManager.Users.Select(u => u.Id).ToListAsync();

            var noticeReceivings = new NoticeReceiving[userIds.Count];

            for (var i = 0; i < userIds.Count; i++)
            {
                noticeReceivings[i] = new NoticeReceiving
                {
                    Id       = Guid.NewGuid(),
                    UserId   = userIds[i],
                    NoticeId = dto.Id,
                    IsRead   = false
                };
            }

            await _noticeReceivingRepo.InsertAsync(noticeReceivings);

            await _client.AddNoticeAsync(dto);
        }
 public async Task AddNoticeAsync(NoticeInputDto dto)
 {
     await connection.InvokeAsync("NoticeAll", dto);
 }