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; }
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; }
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 }); } }
public void APublisherIsAddedToTheStack() { NotificationStack.Received().AddMessagePublisher <Message>(Arg.Any <IMessagePublisher>(), Region.SystemName); }
public void HandlerIsAddedToBus() { NotificationStack.Received().AddMessageHandler(_handler); }
public void TheMessageIsPublished() { NotificationStack.Received().Publish(_message); }
public void ThatMonitorIsAddedToTheStack() { NotificationStack.Received().Monitor = _monitor; }