public GetAllNotificationsResponse GetAllNotifications(GetAllNotificationsRequest request)
        {
            var response = new GetAllNotificationsResponse();

            try
            {
                Guard.ArgNotNull(request, "request");

                Notification[] results = _unitOfWork.NotificationRepository.Get(d => d.Id > 0).ToArray();
                Guard.ArgNotNull(results, "results");

                var quickInfoResults = new List<NotificationQuickInfo>(results.Count());
                quickInfoResults.AddRange(results.Select(
                    notification => new NotificationQuickInfo
                                        {
                                            Id = notification.Id,
                                            Text = notification.Text
                                        }));
                response.Success = true;
                response.Notifications = quickInfoResults.AsEnumerable();
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.FailureInformation = ex.Message;
                Logger.LogError("GetAllNotifications Method Failed", ex);
            }

            return response;
        }
Ejemplo n.º 2
0
        public IHttpActionResult GetAll(GetAllNotificationsRequest request)
        {
            var data = _notificationManipulation.GetAllNotifications();

            if (data == null)
            {
                return(NotFound());
            }

            return(Ok(new GetAllNotificationsResponse()
            {
                Data = data,
                Success = Common.Enumerations.ResponseStatus.Succeeded
            }));
        }