public void Check() { NotificationRepository repository = new NotificationRepository(); IEnumerable<MailNotificationMessage> list = repository.GetDocuments() as IEnumerable<MailNotificationMessage>; bool controldummy; foreach (MailNotificationMessage item in list) { try { item.SendMail(); controldummy = true; } catch (Exception) { controldummy = false; item.Status = EmailStatus.ERROR; } if (controldummy) item.Status = EmailStatus.SEND; item.TryCount++; repository.UpdateDocument(item); } }
public override System.Threading.Tasks.Task OnConnected() { //Create an instance of the Repository class NotificationRepository objRepository = new NotificationRepository(); string name = Context.User.Identity.GetUserId(); _connections.Add(name, Context.ConnectionId); //refreshNotification is the client side method which will be writing in the future section. GetLogin() is a static extensions extract just the login name scrapping the domain name // Clients.User(Context.User.Identity.GetUserId()).refreshNotification(objRepository.GetUserNotifications(Convert.ToInt32(Context.User.Identity.GetUserId()))); dynamic client = null; foreach (var connectionId in _connections.GetConnections(name.ToString())) { client = Clients.Client(connectionId); } List <UserNotifications> notifications = objRepository.GetUserNotifications(name); client.refreshNotification(notifications); return(base.OnConnected()); }
public async Task Should_Set_Notification_Result_To_Failure_If_User_Not_Found() { var userIds = new List <Guid> { Guid.NewGuid() }; await CreateSmsNotificationAsync(userIds, Text, new Dictionary <string, object> { { ExtraPropertyKey, ExtraPropertyValue } }); var notification = (await NotificationRepository.GetListAsync()).First(); await SmsNotificationSendingJob.ExecuteAsync(new SmsNotificationSendingJobArgs(notification.Id)); notification = await NotificationRepository.GetAsync(notification.Id); notification.Success.ShouldBe(false); notification.CompletionTime.ShouldNotBeNull(); notification.FailureReason.ShouldBe(NotificationConsts.FailureReasons.ReceiverInfoNotFound); }
public async Task Should_Set_Notification_Result_To_Success() { var userIds = new List <Guid> { NotificationServiceProviderMailingTestConsts.FakeUser1Id }; await CreateSmsNotificationAsync(userIds, Text, new Dictionary <string, object> { { ExtraPropertyKey, ExtraPropertyValue } }); var notification = (await NotificationRepository.GetListAsync()).First(); await SmsNotificationSendingJob.ExecuteAsync(new SmsNotificationSendingJobArgs(notification.Id)); notification = await NotificationRepository.GetAsync(notification.Id); notification.Success.ShouldBe(true); notification.CompletionTime.ShouldNotBeNull(); notification.FailureReason.ShouldBeNull(); }
void reloadNotifications(string inProgID, string inProgType) { NotificationRepository notificationRep = new NotificationRepository(AppDelegate.DatabaseContext); List <NotificationDO> notificationDOs = notificationRep.GetEntities().ToList(); if (notificationDOs != null && notificationDOs.Count > 0) { notificationDOs = notificationDOs.OrderByDescending(i => i.ID).ToList(); } DateTime today = DateTime.Today; List <NotificationDO> prevNotifications = new List <NotificationDO>(); prevNotifications = notificationDOs.Where(n => n.NotificationDate < today) != null?notificationDOs.Where(n => n.NotificationDate < today).ToList() : prevNotifications; foreach (var prevNotification in prevNotifications) { notificationRep.DeleteEntity(prevNotification.ID); notificationDOs.Remove(prevNotification); } List <Model.Notifications> notifications = Converter.GetNotificationList(notificationDOs); if (inProgID != "COMPLETE") { Model.Notifications inProgressNotification = notifications.Find(n => n.notificationType == inProgType && n.notificationTypeID == inProgID); if (inProgressNotification != null) { inProgressNotification.inProgress = true; //AppDelegate.dataSync.notifiy-= notificationChange; } } notifySource2 nsrc = new notifySource2(notifications); NotifyTable.Source = nsrc; NotifyTable.RowHeight = 100.0f; NotifyTable.TableFooterView = new UIView(new CoreGraphics.CGRect(0, 0, 0, 0)); NotifyTable.ReloadData(); }
public void Update(CreateVM vm, NotificationRepository notificationRepo, Func <int, string, Task> notify) { TEntity currAd = GetById(vm.Id); if (vm.Title != null && vm.Title.Trim() != "" && vm.Title != currAd.Title) { currAd.Title = vm.Title; } else if (vm.Description != null && vm.Description.Trim() != "" && vm.Description != currAd.Description) { currAd.Description = vm.Description; } else if (vm.Price != 0 && vm.Price != currAd.Price) { currAd.Price = vm.Price; string message = $"<a href='/Home/Ad/?id={vm.Id}&category={vm.Category}'>{currAd.Title}`s</a> new price is {currAd.Price} <span class='notification-date'>[${DateTime.Now}]</span>"; int userId; for (int i = 0; i < currAd.Subscribers.Count; i++) { userId = currAd.Subscribers[i]; notificationRepo.Create(new Notification(message, NotificationType.PriceTrack, userId)); notify(userId, message); } } else if (vm.PhotoFile != null) { using (var binaryReader = new BinaryReader(vm.PhotoFile.OpenReadStream())) { byte[] photoBytes = binaryReader.ReadBytes((int)vm.PhotoFile.Length); if (currAd.Photo != photoBytes) { currAd.Photo = photoBytes; } } } ctx.SaveChanges(); }
public void SendNotification(string connectionString, int id, string code) { Site site; using (new QPConnectionScope(connectionString)) { var article = ArticleRepository.GetById(id); if (article == null) { throw new ArgumentException(string.Format(ArticleStrings.ArticleNotFound, id)); } site = article.Content.Site; } var repository = new NotificationRepository(); var codes = code.Split(';'); foreach (var currentCode in codes) { repository.SendNotification(connectionString, site.Id, currentCode, id, site.IsLive || site.AssembleFormatsInLive); } }
private async Task <Dictionary <string, string> > GenerateDuplicateNhsNumberNotificationUrlsAsync(string nhsNumber, NotificationGroup group) { // If NhsNumber is empty or does not pass validation - return null // Potential duplication of validation here so that both Server and Dynamic/JS routes to warnings // can use the same method. if (string.IsNullOrEmpty(nhsNumber) || !string.IsNullOrEmpty( ValidationService.GetPropertyValidationResult <PatientDetails>("NhsNumber", nhsNumber, false).Content)) { return(null); } var notificationIds = await NotificationRepository.GetNotificationIdsByNhsNumberAsync(nhsNumber); var idsInGroup = group?.Notifications?.Select(n => n.NotificationId) ?? new List <int>(); var filteredIds = notificationIds .Except(idsInGroup) .Where(n => n != NotificationId) .ToDictionary( id => id.ToString(), id => RouteHelper.GetNotificationPath(id, NotificationSubPaths.Overview)); return(filteredIds); }
// ReSharper disable once UnusedMember.Global public async Task <IActionResult> OnGetAsync() { Notification = await NotificationRepository.GetNotificationAsync(NotificationId); if (Notification == null) { return(NotFound()); } await TryGetLinkedNotificationsAsync(); await AuthorizeAndSetBannerAsync(); if (PermissionLevel == PermissionLevel.None) { return(RedirectToPage("/Notifications/Overview", new { NotificationId })); } Changes = (await _notificationChangesService.GetChangesList(NotificationId)) .OrderByDescending(change => change.Date); PrepareBreadcrumbs(); return(Page()); }
public void DeleteByObjectTest() { // Arrange NotificationRepository notificationRepository = new NotificationRepository(); notificationRepository.SetDbContext(testContext); Notification notificationToDelete = testContext.Notifications.First(); int expectedCountBeforeDelete = TestData.NotificationsCount; int expectedCountAfterDelete = TestData.NotificationsCount - 1; // Act int actualCountBeforeDelete = testContext.Notifications.Count(); notificationRepository.Delete(notificationToDelete); testContext.SaveChanges(); int actualCountAfterDelete = testContext.Notifications.Count(); // Assert Assert.Equal(expectedCountBeforeDelete, actualCountBeforeDelete); Assert.Equal(expectedCountAfterDelete, actualCountAfterDelete); Assert.DoesNotContain(notificationToDelete, testContext.Notifications); }
public async Task <IActionResult> OnPostAsync() { Notification = await NotificationRepository.GetNotificationAsync(NotificationId); TransferAlert = await _alertRepository.GetOpenAlertByNotificationId <TransferAlert>(NotificationId); await AuthorizeAndSetBannerAsync(); if (!ModelState.IsValid) { return(Page()); } if (AcceptTransfer == true) { await AcceptTransferAndDismissAlertAsync(); return(Partial("_AcceptedTransferConfirmation", this)); } await RejectTransferAndDismissAlertAsync(); return(Partial("_RejectedTransferConfirmation", this)); }
public void DeleteByPredicateTest() { // Arrange NotificationRepository notificationRepository = new NotificationRepository(); notificationRepository.SetDbContext(testContext); Expression <Func <Notification, bool> > predicateToDelete = n => n.EmergencyLevel == Enums.EmergencyLevel.Info; int expectedCountBeforeDelete = TestData.NotificationsCount; int expectedCountAfterDelete = TestData.NotificationsCount - testData.InfoNotificationsCount; // Act int actualCountBeforeDelete = testContext.Notifications.Count(); notificationRepository.Delete(predicateToDelete); testContext.SaveChanges(); int actualCountAfterDelete = testContext.Notifications.Count(); // Assert Assert.Equal(expectedCountBeforeDelete, actualCountBeforeDelete); Assert.Equal(expectedCountAfterDelete, actualCountAfterDelete); Assert.DoesNotContain(testContext.Notifications, n => n.EmergencyLevel == Enums.EmergencyLevel.Info); }
public async Task <IActionResult> OnGetAsync() { Notification = await NotificationRepository.GetNotificationAsync(NotificationId); TransferAlert = await _alertRepository.GetOpenAlertByNotificationId <TransferAlert>(NotificationId); await AuthorizeAndSetBannerAsync(); // Check edit permission of user and redirect if not allowed if (!await _authorizationService.IsUserAuthorizedToManageAlert(User, TransferAlert)) { return(RedirectToPage("/Notifications/Overview", new { NotificationId })); } if (TransferAlert == null) { return(RedirectToPage("/Notifications/Overview", new { NotificationId })); } var hospitals = await _referenceDataRepository.GetHospitalsByTbServiceCodesAsync( new List <string> { TransferAlert.TbServiceCode }); Hospitals = new SelectList(hospitals, nameof(Hospital.HospitalId), nameof(Hospital.Name)); var caseManagers = await _referenceDataRepository.GetCaseManagersByTbServiceCodesAsync( new List <string> { TransferAlert.TbServiceCode }); CaseManagers = new SelectList(caseManagers, nameof(Models.Entities.User.Username), nameof(Models.Entities.User.DisplayName)); TargetCaseManagerUsername = TransferAlert.CaseManagerUsername; return(Page()); }
public List <Log4Net_Error> GetNotificationsByUserUser(string idUser) { NotificationRepository <Log4Net_Error> notirepo = new NotificationRepository <Log4Net_Error>(); SUser suser = new SUser(); var user = suser.GetUserById(new Guid(idUser)); var categories = user.Skills.Where(e => e.Visible).Select(e => e.Name).Distinct(); StringBuilder sb = new StringBuilder(); if (user.Empresa) { sb.Append("where ( [Message] like 'Postulación Oferta%')"); } else { sb.Append("where ( [Message] like 'Postulación Oferta%' Or [Message] like 'Proyecto finalizado%')"); } foreach (var cat in categories) { sb.Append("Or [Message] like '%Categoria:" + cat + "'"); } return(notirepo.GetList(sb.ToString()).ToList()); }
public async Task <IActionResult> OnPostConfirmAsync() { Notification = await NotificationRepository.GetNotificationAsync(NotificationId); if (!ModelState.IsValid) { NotificationBannerModel = new NotificationBannerModel(Notification); return(Page()); } if (Notification == null) { return(NotFound()); } if (Notification.NotificationStatus == NotificationStatus.Draft) { await Service.DeleteNotificationAsync(NotificationId, DeletionReason); return(Partial("_DeleteConfirmation", this)); } return(RedirectToPage("/Notifications/Overview", new { NotificationId })); }
public async Task <IActionResult> OnGetAsync() { Notification = await NotificationRepository.GetNotificationWithAllInfoAsync(NotificationId); if (Notification == null) { return(NotFound()); } await GetLinkedNotificationsAsync(); await AuthorizeAndSetBannerAsync(); if (PermissionLevel == PermissionLevel.None) { return(RedirectToPage("/Notifications/Overview", new { NotificationId })); } TestData = Notification.TestData; CultureAndResistance = await _cultureAndResistanceService.GetCultureAndResistanceDetailsAsync(NotificationId); Specimens = await _specimenService.GetMatchedSpecimenDetailsForNotificationAsync(NotificationId); return(Page()); }
public ActionResult Notifications(string notification, int limit) { try { using (var repository = new NotificationRepository()) { var data = repository.GetNotifications(notification, limit); return(Json(new ResponseMessageModel { HasError = false, Data = data, })); } } catch (Exception ex) { SharedLogger.LogError(ex); return(Json(new ResponseMessageModel { HasError = false, Message = "Se presentó un problema al momento de consultar la información", })); } }
public ActionResult DoUpsert(StoreNotificationModel model) { try { if (ModelState.IsValid == false) { return(Json(new ResponseMessageModel { HasError = true, Title = ResShared.TITLE_REGISTER_FAILED, Message = ResShared.ERROR_INVALID_MODEL })); } var userId = User.Identity.GetUserId(); using (var repository = new NotificationRepository()) { using (var trans = repository.Db.Database.BeginTransaction()) { var response = repository.InsertNotification(model, userId); trans.Commit(); return(Json(response)); } } } catch (Exception ex) { SharedLogger.LogError(ex); return(Json(new ResponseMessageModel { HasError = true, Title = ResShared.TITLE_REGISTER_FAILED, Message = ResShared.ERROR_UNKOWN })); } }
public NotificationsResponse GetNotificationsByUser(int userId) { var response = new NotificationsResponse(); try { var notificationRepository = new NotificationRepository(); var notifications = notificationRepository.Query().Where(x => x.CreateBy == userId).OrderByDescending(x => x.CreatedDate).ToList(); var newNotificationsCount = 0; foreach (var notification in notifications) { bool wasViewed = (notification.WasViewed.HasValue) ? notification.WasViewed.Value : false; if (!wasViewed) { newNotificationsCount++; } response.NotificationsList.Add(new NotificationDto() { idNotification = notification.idNotification, CreatedDate = notification.CreatedDate.Value, Text = notification.Text, WasViewed = notification.WasViewed }); } response.NotificationsCount = newNotificationsCount; notificationRepository.Dispose(); response.Acknowledgment = true; response.Message = "Success"; } catch (Exception ex) { response.Acknowledgment = false; response.Message = ex.Message; } return(response); }
public async Task <IActionResult> OnGetAsync() { PrepareBreadcrumbs(); Notification = await NotificationRepository.GetNotificationWithAllInfoAsync(NotificationId); if (Notification == null) { return(NotFound()); } NotificationId = Notification.NotificationId; await GetLinkedNotificationsAsync(); await GetAlertsAsync(); await AuthorizeAndSetBannerAsync(); if (PermissionLevel == PermissionLevel.None || (PermissionLevel == PermissionLevel.ReadOnly && Notification.NotificationStatus == NotificationStatus.Draft)) { return(Partial("./UnauthorizedWarning", this)); } // This check has to happen after authorization as otherwise patient will redirect to overview and we'd be stuck in a loop. if (Notification.NotificationStatus == NotificationStatus.Draft) { return(RedirectToPage("./Edit/PatientDetails", new { NotificationId })); } CultureAndResistance = await _cultureAndResistanceService.GetCultureAndResistanceDetailsAsync(NotificationId); TreatmentPeriods = Notification.TreatmentEvents.GroupEpisodesIntoPeriods(Notification.IsPostMortemAndHasCorrectEvents); AddDenotificationEventIfDenotified(); CalculateTreatmentOutcomes(); return(Page()); }
private void SendRequestToZapier(bool shouldSendEmail, Notification notification, NotificationRepository notificationRepository) { if (!shouldSendEmail) { return; } var queryString = notification.ZapierUrl; queryString += $"?email={notification.Email}&bookTitle={notification.BookTitle}&userName={notification.UserName}&siteUrl={notification.SiteUrl}"; HttpClient client = new HttpClient(); // Add an Accept header for JSON format. client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = client.GetAsync(queryString).Result; if (response.IsSuccessStatusCode) { notification.IsSentToZapier = true; notification.SentToZapierDateTime = DateTime.UtcNow; notificationRepository.UpdateNotification(notification); } }
public async Task <ContentResult> OnPostValidateMDRDetailsDate([FromBody] DateValidationModel validationData) { var isLegacy = await NotificationRepository.IsNotificationLegacyAsync(NotificationId); return(ValidationService.GetDateValidationResult <MDRDetails>(validationData.Key, validationData.Day, validationData.Month, validationData.Year, isLegacy)); }
public void InstanceRepositories(DbContext context, DbContextTransaction transaction) { _notificationRepository = new NotificationRepository(context, transaction); _clientNotificationRepository = new ClientNotificationRepository(context, transaction); _clientRepository = new ClientRepository(context, transaction); }
public NotificationVM(NotificationM notification, NotificationRepository repo) { _notification = notification; _repo = repo; }
public NotificationManager() { NotifRepo = new NotificationRepository(); }
public void TestInitialize() { context = new ApplicationDbContext(); notificationService = new NotificationService(context); notificationRepository = new NotificationRepository(context); }
public async Task <IdResult> Submit(Models.Notification item) { if (item == null) { return(new IdResult() { IsOk = false, ErrorMessage = "No post info" }); } Common.Model.Notification itemDb = null; var dbUser = DbUser; using (var transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) using (NotificationRepository _notificationRepository = new NotificationRepository(Context, dbUser, null)) { { try { if (item.Id == Guid.Empty) { //if (item.SelectedContact != null) //{ // var contactCircle = _userContactRepository.GetCircleByUsersPair(dbUser, // item.SelectedContact.Id); // if (contactCircle != null) // { // item.SelectedCircle = new Circle() { Id = contactCircle.Id }; // } //} itemDb = new Common.Model.Notification() { }; _notificationRepository.Create(itemDb); } else { itemDb = _notificationRepository.GetById(item.Id); _notificationRepository.Update(itemDb); } Context.SaveChanges(); if (itemDb != null) { transactionScope.Complete(); return(new IdResult() { IsOk = true, Id = itemDb.Id }); } return(new IdResult() { IsOk = false, ErrorMessage = "Error On Save" }); } catch (Exception e) { LogHelper.WriteError(e); return(new IdResult() { IsOk = false, ErrorMessage = e.ToString() }); } } } }
public NotificationController(NotificationRepository notificationRepository, IMapper mapper) { _notificationRepository = notificationRepository; _mapper = mapper; }
public async Task <JsonResult> OnPostNhsNumberDuplicates([FromBody] NhsNumberValidationModel validationData) { var group = await NotificationRepository.GetNotificationGroupAsync(validationData.NotificationId); return(new JsonResult(await GenerateDuplicateNhsNumberNotificationUrlsAsync(NotificationFieldFormattingHelper.FormatNhsNumberForModel(validationData.NhsNumber), group))); }
protected override async Task <Notification> GetNotificationAsync(int notificationId) { return(await NotificationRepository.GetNotificationWithTestsAsync(notificationId)); }
protected override async Task <Notification> GetNotificationAsync(int notificationId) { return(await NotificationRepository.GetNotificationWithSocialContextVenuesAsync(notificationId)); }