예제 #1
0
        protected override async Task Handle(DeleteOldContactsCommand request, CancellationToken cancellationToken)
        {
            var interval      = DateTime.UtcNow.Add(-request.DeleteInterval);
            int intervalEpoch = (int)dateTimeConvertor.DateTimeToUnixTimestamp(interval);

            await repository.DeleteContactsAsync(intervalEpoch, cancellationToken);

            await repository.UnitOfWork.SaveChangesAsync(cancellationToken);
        }
예제 #2
0
        public async Task <IEnumerable <AlertResponse> > Handle(GetAlertsForProfileQuery request, CancellationToken cancellationToken)
        {
            var alerts =
                await repository.GetAlertsForProfileNt(request.ProfileId, request.DeviceId)
                .ToListAsync(cancellationToken);

            return(alerts.Select(x => new AlertResponse
            {
                Id = x.Id,
                Content = x.Content,
                Created = convertService.DateTimeToUnixTimestamp(x.CreatedOn)
            }));
        }
        public async Task <AlertResponse> Handle(GetLastAlertForProfileQuery request, CancellationToken cancellationToken)
        {
            var lastAlert = await repository.GetAlertsForProfileNt(request.ProfileId, request.DeviceId)
                            .FirstOrDefaultAsync(cancellationToken);

            var result = lastAlert != null ? new AlertResponse
            {
                Id      = lastAlert.Id,
                Created = convertService.DateTimeToUnixTimestamp(lastAlert.CreatedOn),
                Content = lastAlert.Content
            } : new AlertResponse();

            return(result);
        }