Пример #1
0
        public void GeneralTest()
        {
            var fromUser = Database.CreateActiveUser("*****@*****.**", Role.CaseWorker);
            var toUser = Database.CreateActiveUser("*****@*****.**", Role.CaseWorker);
            var fromLogin = UserManagementTests.Login(fromUser.Email, Database.Password, Database.Phrase);
            var toLogin = UserManagementTests.Login(toUser.Email, Database.Password, Database.Phrase);

            var client = DefaultUser.CreateWebApiClient();
            var createNotification = new CreateNotification
            {
                ToUserId = toUser.Id,
                Message = "test message",
                Delivery = CreateNotification.DeliveryType.Both,
            };
            client.SendNotification(fromLogin.SecurityToken, createNotification);
            var fromNotifications = client.GetNotifications(fromLogin.SecurityToken);
            var toNotifications = client.GetNotifications(toLogin.SecurityToken);
            client.DismissNotification(toLogin.SecurityToken, toNotifications[0].Id);
            var toNotifications2 = client.GetNotifications(toLogin.SecurityToken);

            Assert.AreEqual(0, fromNotifications.Length);
            Assert.AreEqual(1, toNotifications.Length);
            Assert.AreEqual(0, toNotifications2.Length);
            Assert.AreEqual("test message", toNotifications[0].Message);
            Assert.Less((DateTime.Now - toNotifications[0].DateTime).TotalSeconds, 5);
        }
 private CreateNotification CreateNotification(string message, Guid userId, CreateNotification.DeliveryType type)
 {
     var result = new CreateNotification()
     {
         Delivery = type,
         Message = message,
         ToUserId = userId,
     };
     return result;
 }
        private CreateNotificationAll CreateNotificationAll(string message, int caseId, CreateNotification.DeliveryType type)
        {
            var result = new CreateNotificationAll()
            {
                Delivery = type,
                Message = message,
                CaseId = caseId,
            };

            return result;
        }
Пример #4
0
 public void CreateMessage(Guid id, Guid fromUserId, Guid toUserId, string message,
     CreateNotification.DeliveryType delivery)
 {
     if (delivery == CreateNotification.DeliveryType.Both || delivery == CreateNotification.DeliveryType.System)
     {
         _database.CreateMessage(new Message
         {
             Id = id,
             FromUserId = fromUserId,
             ToUserId = toUserId,
             Text = message,
             Created = DateTime.Now,
             Accepted = null,
         });
     }
     if (delivery == CreateNotification.DeliveryType.Both || delivery == CreateNotification.DeliveryType.Email)
     {
         // TODO: mail notification
     }
 }