public void Upsert(core.PushNotification notify)
        {
            if (notify == null)
            {
                throw new ArgumentNullException("notify");
            }

            var alreadyExistNotify = _innerList.FirstOrDefault(x => x.Id == notify.Id);

            if (alreadyExistNotify != null)
            {
                _innerList.TryTake(out alreadyExistNotify);
                _innerList.Add(notify);
            }
            else
            {
                var lastEvent = _innerList.OrderByDescending(x => x.Created).FirstOrDefault();
                if (lastEvent != null && lastEvent.ItHasSameContent(notify))
                {
                    lastEvent.IsNew = true;
                    lastEvent.RepeatCount++;
                    lastEvent.Created = DateTime.UtcNow;
                }
                else
                {
                    _innerList.Add(notify);
                }
            }

            _hubSignalR.Clients.All.notification(notify);
        }
        public IHttpActionResult Upsert(PushNotification notify)
        {
			if (notify != null)
			{
				notify.New = true;
				notify.Created = DateTime.UtcNow;
				notify.Creator = User.Identity.Name;
				_pushNotifier.Upsert(notify);
			}
            return Ok(notify);
        }
Exemplo n.º 3
0
 public bool ItHasSameContent(PushNotification other)
 {
     return(other.Title == Title && other.NotifyType == NotifyType && other.Description == Description);
 }
Exemplo n.º 4
0
 public bool ItHasSameContent(PushNotification other)
 {
     return other.Title == Title && other.NotifyType == NotifyType && other.Description == Description;
 }