Пример #1
0
 private void _UpdateModel(ref NotificationStack stackNotification, NotificationStackModel model)
 {
     stackNotification.UserId   = model.UserId;
     stackNotification.Status   = (int)model.Status;
     stackNotification.Priority = (int)model.Priority;
     stackNotification.DeviceId = model.DeviceId;
 }
Пример #2
0
 public NotificationStackModel(NotificationStack model)
 {
     NotificationId   = model.NotificationId;
     UserId           = model.UserId ?? 0;
     Status           = (NotificationStatus)model.Status;
     Priority         = (Priority)model.Priority;
     DeviceId         = model.DeviceId;
     StringifyMessage = model.Message;
 }
Пример #3
0
 public ActionOutput <NotificationStackModel> AddOrUpdateStack(NotificationStackModel model)
 {
     try
     {
         if (model.NotificationId == Guid.Empty)
         {
             var stackNotification = new NotificationStack();
             stackNotification.NotificationId = Guid.NewGuid();
             _UpdateModel(ref stackNotification, model);
             stackNotification.CreatedDate = DateTime.UtcNow;
             stackNotification.Message     = "";
             Context.NotificationStacks.Add(stackNotification);
             Context.SaveChanges();
             model.Message.NotificationId = stackNotification.NotificationId;
             model.Message.ReceiverId     = model.UserId;
             stackNotification.Message    = model.Message.GetJson();
             Context.SaveChanges();
             return(new ActionOutput <NotificationStackModel>()
             {
                 Object = new NotificationStackModel(stackNotification),
                 Status = ActionStatus.Successfull
             });
         }
         else
         {
             var stackNotification = Context.NotificationStacks.Find(model.NotificationId);
             if (stackNotification == null)
             {
                 return new ActionOutput <NotificationStackModel>()
                        {
                            Status = ActionStatus.Error
                        }
             }
             ;
             _UpdateModel(ref stackNotification, model);
             stackNotification.Message = model.Message.GetJson();
             Context.SaveChanges();
             return(new ActionOutput <NotificationStackModel>()
             {
                 Object = new NotificationStackModel(stackNotification),
                 Status = ActionStatus.Successfull
             });
         }
     }
     catch (DbEntityValidationException e)
     {
         return(new ActionOutput <NotificationStackModel>()
         {
             Status = ActionStatus.Error
         });
     }
 }
Пример #4
0
 public void APublisherIsAddedToTheStack()
 {
     NotificationStack.Received().AddMessagePublisher <Message>(Arg.Any <IMessagePublisher>(), Region.SystemName);
 }
 public void HandlerIsAddedToBus()
 {
     NotificationStack.Received().AddMessageHandler(_handler);
 }
Пример #6
0
 public void TheMessageIsPublished()
 {
     NotificationStack.Received().Publish(_message);
 }
Пример #7
0
 public void ThatMonitorIsAddedToTheStack()
 {
     NotificationStack.Received().Monitor = _monitor;
 }