public async Task <ActionResult> ConfirmNoteItems(ConfirmNoteItemsDTO availableItems) { NoteModel note = await noteCosmosDBService.GetNote(availableItems.NoteID); if (note != null) { Model.Shop shop = note.Shops.First(x => x.ShopEmail.Equals(availableItems.UserEmail)); shop.Notes = mapper.Map <NoteModel>(availableItems).Notes; note.Shops.RemoveAll(x => x.ShopEmail.Equals(availableItems.UserEmail)); shop.ResponseTime = DateTime.Now; shop.ShopStatus = 1; note.Shops.Add(shop); if (await noteCosmosDBService.ReplaceDocumentAsync(note.SelfLink, note)) { string title = $"The shop {shop.ShopName} has responded to your order"; var data = new Dictionary <string, string>(); data.Add("orderid", note.Id); var notificationData = new NotificationData() { msgBody = title, msgTitle = "A Shop has responed to your order", tokenList = note.PhoneGuid //options = data }; pushNotificationService.SendNotification(notificationData); return(Ok("Note Successfully Updated")); } return(StatusCode(500, "Unable to update the status")); } return(BadRequest("Specified Note doesn't exist")); }
public async Task <IActionResult> RequestSpecifications() { PushSubscription pushSubscription = new PushSubscription() { Endpoint = Request.Form["PushEndpoint"], P256DH = Request.Form["PushP256DH"], Auth = Request.Form["PushAuth"] }; PushPayload pushPayload = new PushPayload(); int pharmacyId = int.Parse(Request.Form["pharmacyId"]); int drugId = int.Parse(Request.Form["drugId"]); var pharmacySystem = await _pharmacySystemService.Get(pharmacyId); if (_adapterContext.SetPharmacySystemAdapter(pharmacySystem) == null) { pushPayload.Title = "Unsuccess"; pushPayload.Message = "Error occured while downloading specification!"; _pushNotificationService.SendNotification(pushSubscription, pushPayload); return(RedirectToAction("DrugList", new { id = pharmacyId })); } if (_adapterContext.PharmacySystemAdapter.GetDrugSpecifications(drugId)) { pushPayload.Title = "Success"; pushPayload.Message = "Specification successfully downloaded!"; } else { pushPayload.Title = "Unuccess"; pushPayload.Message = "Error occured while downloading specification!"; } _pushNotificationService.SendNotification(pushSubscription, pushPayload); return(RedirectToAction("DrugList", new { id = pharmacyId })); }
public async Task <ApiResponse <LessonDto> > Handle(OrderNewLessonByStudentRequest request, CancellationToken cancellationToken) { VerifyAccountType(); var orderNewLessonByStudentDto = request.NewLessonDto; var userId = _identityService.GetUserIdentity(); var orderLessonRequestResult = await _studentService.OrderLessonAsync(userId, orderNewLessonByStudentDto); if (orderLessonRequestResult.CompletedWithSuccess) { var newNotification = new PushNotification { Tags = new List <string> { orderNewLessonByStudentDto.TutorId.ToString() }, MobilePlatform = MobilePlatform.apns, Message = "New lesson request arrived!" }; await _pushNotificationService.SendNotification(newNotification); newNotification.MobilePlatform = MobilePlatform.fcm; await _pushNotificationService.SendNotification(newNotification); newNotification.MobilePlatform = MobilePlatform.wns; await _pushNotificationService.SendNotification(newNotification); } return(orderLessonRequestResult); }
public async Task <ActionResult> SubmitNote(NoteDTO noteDTO) { List <ShopModel> shops = await userCosmosDBService.GetShops(noteDTO.Category); if (shops?.Count > 0) { List <ShopModel> nearbyShops = DistanceCalculator.GetDistance(shops, noteDTO.Latitude, noteDTO.Longitude); string body = string.Format("You have received a new order request from {0}", noteDTO.UserPhoneNumber); var phoneGuidList = nearbyShops.Where(s => s.PhoneGuid != null)?.Select(shop => shop.PhoneGuid).ToList(); NotificationData notificationData = null; var data = new Dictionary <string, string>(); data.Add("orderid", "test"); if (phoneGuidList.Count() > 0) { if (phoneGuidList.Count() == 1) { notificationData = new NotificationData() { msgBody = body, msgTitle = "You have received a new order request", tokenList = phoneGuidList[0] //options = data }; } else { notificationData = new NotificationData() { msgBody = body, msgTitle = "You have received a new order request", tokenList = phoneGuidList //options = data }; } pushNotificationService.SendNotification(notificationData); } //Mapping NoteModel note = mapper.Map <NoteModel>(noteDTO); ShopsModel shopsModel = new ShopsModel(); shopsModel.ShopModel = nearbyShops; Model.Shops shopsresult = mapper.Map <Model.Shops>(shopsModel); note.Shops = shopsresult.Shop; //Assigning fields note.NoteTime = DateTime.Now; note.Status = 0; note = await noteCosmosDBService.CreateAndReturnDocumentAsync(note); if (note != null) { return(Ok(mapper.Map <NoteInfo>(note))); } } return(Ok("No shops found with the matching criteria")); }
public async Task <IActionResult> SendPrescription(PrescriptionForm form) { PushSubscription pushSubscription = new PushSubscription() { Endpoint = Request.Form["PushEndpoint"], P256DH = Request.Form["PushP256DH"], Auth = Request.Form["PushAuth"] }; PushPayload pushPayload = new PushPayload(); if (!FormValid(form)) { pushPayload.Title = "Unsuccess"; pushPayload.Message = "Invalid prescription data!"; _pushNotificationService.SendNotification(pushSubscription, pushPayload); return(RedirectToAction("Index")); } var reportFilePath = "Resources"; string reportFileName = Guid.NewGuid().ToString() + ".json"; var prescription = new { drugId = form.Drug, jmbg = form.Patient }; string json = JsonConvert.SerializeObject(prescription, Formatting.Indented); try { System.IO.File.WriteAllText(reportFilePath + "/" + reportFileName, json); } catch (Exception ex) { Console.WriteLine(ex); pushPayload.Title = "Unsuccess"; pushPayload.Message = "Error occured while creating prescription file!"; _pushNotificationService.SendNotification(pushSubscription, pushPayload); } var pharmacy = await _pharmacySystemService.Get(form.PharmacySystem); if (_adapterContext.SetPharmacySystemAdapter(pharmacy) != null) { if (_adapterContext.PharmacySystemAdapter.SendDrugConsumptionReport(reportFilePath, reportFileName)) { pushPayload.Title = "Success"; pushPayload.Message = "Prescription successfully created and uploaded!"; } else { pushPayload.Title = "Unsuccess"; pushPayload.Message = "Prescription upload to " + pharmacy.Name + @" unsuccessfull!"; } _pushNotificationService.SendNotification(pushSubscription, pushPayload); } return(RedirectToAction("Index")); }
public async Task <IActionResult> GetPushSubscriptions() { var subs = await this.context.PushSubscription.ToListAsync(); pushService.SendNotification(subs.Count() + " Subscriptions have been retreived"); return(Ok(subs)); }
public async Task SendPostedNotificationForSuppliersJob() { var mobileAlerts = await _mobileQueries.GetPendingMessages(); foreach (var item in mobileAlerts) { item.MessageSent(); _pushNotificationService.SendNotification(item.Message, item.DeviceToken.DeviceTokenValue); } await _mobileCommands.UpdatListeMobileAlert(mobileAlerts); }
private async Task OnNotificationRequestAsync(NotificationType type) { switch (type) { case NotificationType.DelayedFlight: var delayTs = TimeSpan.FromSeconds(Settings.DelayedTime); await _pushNotificationService.SendNotification(NotificationType.DelayedFlight, delayTs); break; case NotificationType.GiveFeedback: var feedbackTs = TimeSpan.FromSeconds(Settings.FeedbackTime); await _pushNotificationService.SendNotification(NotificationType.GiveFeedback, feedbackTs); break; default: break; } }
public IActionResult Broadcast(int id) { var notification = _notificationService.GetTaggedNotification(id); if (notification != null) { var subscriptions = _notificationService.GedBroadcastDevices(notification); foreach (var subscription in subscriptions) { _webPushService.SendNotification(subscription, notification); } } else { return(NotFound()); } return(Ok()); }
public async Task <IActionResult> Index(DateRangeDTO dateRangeDto) { DateRange dateRange = new DateRange(dateRangeDto.From, dateRangeDto.To); PushSubscription pushSubscription = new PushSubscription() { Endpoint = Request.Form["PushEndpoint"], P256DH = Request.Form["PushP256DH"], Auth = Request.Form["PushAuth"] }; PushPayload pushPayload = new PushPayload(); var reports = await _drugService.GetDrugConsuption(dateRange); if (reports == null) { pushPayload.Title = "Unsuccess"; pushPayload.Message = "Comunication error!"; _pushNotificationService.SendNotification(pushSubscription, pushPayload); return(RedirectToAction("Index")); } if (reports.Count == 0) { pushPayload.Title = "Unsuccess"; pushPayload.Message = "Nothing found in given data range!"; _pushNotificationService.SendNotification(pushSubscription, pushPayload); return(RedirectToAction("Index")); } var json = JsonConvert.SerializeObject(reports, Formatting.Indented); var reportFileName = $"{dateRange.From:yyyy-MM-dd}-to-{dateRange.To:yyyy-MM-dd}-report.json"; var reportFilePath = "Resources"; try { System.IO.File.WriteAllText(Path.Combine(reportFilePath, reportFileName), json); } catch (Exception dnfe) { Console.WriteLine(dnfe); pushPayload.Title = "Unsuccess"; pushPayload.Message = "Error occured while creating report file!"; _pushNotificationService.SendNotification(pushSubscription, pushPayload); return(RedirectToAction("Index")); } var pharmacySystems = await _pharmacySystemService.GetAll(); foreach (var ps in pharmacySystems) { if (_adapterContext.SetPharmacySystemAdapter(ps) == null) { continue; } if (_adapterContext.PharmacySystemAdapter.SendDrugConsumptionReport(reportFilePath, reportFileName)) { pushPayload.Title = "Success"; pushPayload.Message = "Report successfully created and uploaded to " + ps.Name + "!"; } else { pushPayload.Title = "Unsuccess"; pushPayload.Message = "Report upload to " + ps.Name + " unsuccessfull!"; } _pushNotificationService.SendNotification(pushSubscription, pushPayload); } return(RedirectToAction("Index")); }
public async Task Send(PushNotificationItem pushNotificationItem) { await pushNotificationService.SendNotification(pushNotificationItem); }
public Task Handle(Notification notification, string eventName, CancellationToken cancellationToken) { return(_pushService.SendNotification(notification.GetProperties())); }
public async Task <IActionResult> SendNotification([FromBody] PushMessageViewModel message) { PushMessage pushMessage = new PushMessage(message.Notification) { Topic = message.Topic, Urgency = message.Urgency }; // TODO: This should be scheduled in background await _subscriptionStore.ForEachSubscriptionAsync((PushSubscription subscription) => _notificationService.SendNotification(subscription, pushMessage)); return(NoContent()); }
public async Task <IActionResult> SendNotification([FromBody] string payload) { // TODO: This should be scheduled in background await _subscriptionStore.ForEachSubscriptionAsync((PushSubscription subscription) => _notificationService.SendNotification(subscription, payload)); return(NoContent()); }