public async Task GetByIdTest() { var notificationId = Guid.NewGuid(); var service = new Mock <INotificationHistoryService>(); var response = new NotificationResponse(NotificationEvent.ArticleCreated) { OwnerUserId = UserId }; GetNotificationRequest req = null; service.Setup(x => x.GetAsync(It.IsAny <GetNotificationRequest>())) .Callback <GetNotificationRequest>(request => req = request) .ReturnsAsync(response) .Verifiable(); var controller = new NotificationHistoryController(_logger, service.Object).WithUser(); var result = await controller.GetNotificationByIdAsync(notificationId); service.Verify(); Assert.NotNull(req); Assert.Equal(UserId, req.UserId); Assert.Equal(notificationId, req.NotificationId); var res = Assert.IsType <OkObjectResult>(result); Assert.Equal(response, res.Value); Assert.IsType <NotificationResponse>(res.Value); }
public async Task <IActionResult> GetNotificationByIdAsync(Guid notificationId) { var userId = GetCurrentUserId(); var request = new GetNotificationRequest(userId, notificationId); var res = await _service.GetAsync(request); return(Ok(res)); }
/// <summary> /// Gets a notification. /// </summary> /// <param name = "notificationId">id of the notification</param> /// <returns>notification</returns> public Task <Notification> GetNotification(string notificationId) { var request = new GetNotificationRequest { NotificationId = notificationId }; return(gateway(authenticationContext()) .GetNotificationAsync(request) .ToTask(response => response.Notification)); }
public async Task <NotificationResponse> GetAsync(GetNotificationRequest request) { Ensure.That(request, nameof(request)).IsNotNull(); var notification = await _store.FindAsync(request.NotificationId); if (notification == null || notification.OwnerUserId != request.UserId) { throw new NotFoundException(new ErrorDto(ErrorCode.NotFound, "Notification record does not exist.")); } var response = PopulateNotificationResponse(notification); return(response); }
public async Task <ApiResult <PagedResult <NotificationVm> > > GetAllPaging(GetNotificationRequest request) { var query = from n in _context.Notifications join st in _context.Students on n.Id_User equals st.Id join e in _context.Equipment on n.Id_BLE equals e.Id_BLE into ne from e in ne.DefaultIfEmpty() where n.Status == request.Status select new { n, st, e }; //filter if (!string.IsNullOrEmpty(request.Keyword)) { query = query.Where(x => x.st.FullName.Contains(request.Keyword)); } //Paging int totalRow = await query.CountAsync(); var data = await query.Skip((request.PageIndex - 1) *request.PageSize) .Take(request.PageSize) .Select(x => new NotificationVm() { Id = x.n.Id, NameUser = x.st.FullName, NameEquipment = x.e.Name != null?x.e.Name:x.n.Id_BLE, Reason = x.n.Reason, DateCreate = x.n.DateCreate, DateUpdate = x.n.DateUpdate }).ToListAsync(); var pagedResult = new PagedResult <NotificationVm>() { TotalRecords = totalRow, PageSize = request.PageSize, PageIndex = request.PageIndex, Items = data }; return(new ApiSuccessResult <PagedResult <NotificationVm> >(pagedResult)); }
/// <summary> /// 获取媒体处理通知 /// </summary> /// <param name="request">请求参数信息</param> /// <returns>请求结果信息</returns> public async Task <GetNotificationResponse> GetNotification(GetNotificationRequest request) { return(await new GetNotificationExecutor().Client(this).Execute <GetNotificationResponse, GetNotificationResult, GetNotificationRequest>(request).ConfigureAwait(false)); }
/// <summary> /// 获取媒体处理通知 /// </summary> /// <param name="request">请求参数信息</param> /// <returns>请求结果信息</returns> public GetNotificationResponse GetNotification(GetNotificationRequest request) { return(new GetNotificationExecutor().Client(this).Execute <GetNotificationResponse, GetNotificationResult, GetNotificationRequest>(request)); }
public IHttpActionResult GetNotification([FromUri] GetNotificationRequest getNotificationRequest) { var responses = new Responses(); try { if (Utility.UserId < 0) { return(BadRequest(Utility.INVALID_USER)); } if (getNotificationRequest == null) { getNotificationRequest = new GetNotificationRequest(); } if (getNotificationRequest.PageSize == null) { getNotificationRequest.PageSize = Convert.ToInt32(ConfigurationManager.AppSettings["PageSize"]); } var notification = new Notification() { NotificationId = getNotificationRequest.NotificationId, RegulationId = getNotificationRequest.RegulationId, SearchText = getNotificationRequest.SearchText, IsActive = getNotificationRequest.IsActive, PageNumber = getNotificationRequest.PageNumber, PageSize = Convert.ToInt32(getNotificationRequest.PageSize), IsPagingRequired = (getNotificationRequest.PageNumber != null) ? true : false, OrderBy = getNotificationRequest.OrderBy, OrderByDirection = getNotificationRequest.OrderByDirection }; var notifications = iNotification.GetNotification(notification); var notificationList = new List <GetNotificationResponse>(); foreach (var notificationDetail in notifications) { notificationList.Add(new GetNotificationResponse() { NotificationId = notificationDetail.NotificationId, RegulationId = notificationDetail.RegulationId, RegulationName = notificationDetail.RegulationName, NotificationNumber = notificationDetail.NotificationNumber, RegulationNumber = notificationDetail.RegulationNumber, MasterDirectionId = notificationDetail.MasterDirectionId, MasterDirectionName = notificationDetail.MasterDirectionName, NotificationName = notificationDetail.NotificationName, NotificationTypeName = notificationDetail.NotificationTypeName, NotificationDate = notificationDetail.NotificationDate, NotificationEffectiveDate = notificationDetail.NotificationEffectiveDate, NotificationTypeId = notificationDetail.NotificationTypeId, GSRNo = notificationDetail.GSRNo, GSRDate = notificationDetail.GSRDate, NotificationPDF = notificationDetail.NotificationPDF, GSRPDF = notificationDetail.GSRPDF, IsActive = Convert.ToBoolean(notificationDetail.IsActive), CreatedBy = notificationDetail.CreatedBy, TotalPageCount = notificationDetail.TotalPageCount, TotalRecord = notificationDetail.TotalRecord }); } responses.Status = Utility.SUCCESS_STATUS_RESPONSE; responses.Description = "Notification retrieved successfully"; responses.Response = notificationList; } catch (Exception ex) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while retrieving notification."; Utility.WriteLog("GetNotification", getNotificationRequest, "Error while retrieving notification. (NotificationAdminController)", ex.ToString()); } return(Ok(responses)); }
public async Task <IActionResult> GetAll([FromQuery] GetNotificationRequest request) { var classes = await _notificationService.GetAllPaging(request); return(Ok(classes)); }