private async void LoadListData() { if (CrossConnectivity.Current.IsConnected) { HttpClientHelper apicall = null; if (_type == "User") { apicall = new HttpClientHelper(string.Format(ApiUrls.Url_GetUserNotificationData), Settings.AccessTokenSettings); } else { isAdmin = true; apicall = new HttpClientHelper(string.Format(ApiUrls.Url_GetAdminNotificationData), Settings.AccessTokenSettings); } var response = await apicall.GetResponse <List <AdminNotificationResponseModel> >(); if (response != null) { if (response.Count > 0) { IsStatusVisible = false; foreach (var item in response.ToList()) { AdminNotificationModel notificationModel = new AdminNotificationModel(); if (isAdmin == false) { notificationModel.NotificationInfo = "Admin approved your complaint for service " + item.productName + " in " + item.catagory + " catagory"; } else { notificationModel.NotificationInfo = item.userName + " registered complaint for service " + item.productName + " in " + item.catagory + " catagory"; } NotificationList.Add(notificationModel); } } else { IsStatusVisible = true; } NotificationData = new ReadOnlyObservableCollection <AdminNotificationModel>(NotificationList); } UserDialogs.Instance.HideLoading(); } else { UserDialogs.Instance.HideLoading(); await Application.Current.MainPage.DisplayAlert("Network", AppConstant.NETWORK_FAILURE, "OK"); return; } }
public ServiceResponse GetUserNotifications(PageRecordModel pageRecordModel) { var Name = ""; foreach (var filter in pageRecordModel.Filters) { if (filter.Key == "Name") { Name = pageRecordModel.Filters.Single(x => x.Key == "Name").Value; } } var allUsers = _unitOfWork.UserRepository.GetAll().Where(x => x.RoleID == 2 && x.Name.ToLower().Contains(Name.ToLower())).ToList(); var allNotifications = new List <AdminNotificationModel>(); foreach (var user in allUsers) { foreach (var n in user.Notifications) { AdminNotificationModel notification = new AdminNotificationModel(); notification.userId = user.Id.ToString(); notification.Name = user.Name; notification.Email = user.EmailID; notification.NotificationId = n.id; notification.Notification = n.Text; notification.Date = n.Date; allNotifications.Add(notification); } } var notifications = allNotifications.Skip((pageRecordModel.PageNumber - 1) * pageRecordModel.PageSize).Take(pageRecordModel.PageSize).ToList(); var result = new ServiceResponse { Data = notifications, MultipleData = new Dictionary <string, object>() { { "Notifications", notifications }, { "Total", allNotifications.Count }, }, Success = true }; return(result); }