public async Task <NotifyKioskDto> CreateNotifyKioskAsync(NotifyKioskDto dto) { _log.Debug("CreateNotifyKioskAsync: " + MongoConnectionString); var clientUsers = await Context.ClientUserRepository.FindAllAsync(); IList <NotifyKiosk> NotifyKiosks = new List <NotifyKiosk>(); _log.Debug("clientUsers: " + clientUsers.Count()); var createAt = DateTime.UtcNow; foreach (var clientUser in clientUsers) { var notifyKiosk = DtoToDocument <NotifyKioskDto, NotifyKiosk>(dto); notifyKiosk.CreateAt = createAt; notifyKiosk.Id = MongoHelper.GenerateId(); notifyKiosk.UserId = clientUser.UserId; notifyKiosk.IsRead = false; NotifyKiosks.Add(notifyKiosk); } await Context.NotifyKioskRepository.InsertManyAsync(NotifyKiosks); return(dto); }
public async Task <IHttpActionResult> Post(NotifyKioskDto dto) { try { return(Ok(await _mongoService.CreateNotifyKioskAsync(dto))); } catch (Exception ex) { _log.Error(ex); } return(Ok()); }
public async Task <NotifyKioskDto> AddNotifyAsync(NotifyKioskDto dto) { HttpResponseMessage response = await _proxyService.PostJsonAsync("/api/notify", new { machineId = dto.MachineId, name = dto.Name, groupName = GroupType.ALL, clientId = dto.ClientId, content = dto.Content, status = dto.Status, isRead = false }); response.EnsureSuccessStatusCode(); return(await response.Content.ReadAsAsync <NotifyKioskDto>()); }