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

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

            if (alreadyExistNotify != null)
            {
                _innerList.Remove(alreadyExistNotify);
                _innerList.Add(notify);

            }
            else
            {
                var lastEvent = _innerList.OrderByDescending(x => x.Created).FirstOrDefault();
                if (lastEvent != null && lastEvent.ItHasSameContent(notify))
                {
                    lastEvent.New = true;
                    lastEvent.RepeatCount++;
                    lastEvent.Created = DateTime.UtcNow;
                }
                else
                {
                    _innerList.Add(notify);
                }
            }
         
            _hubSignalR.Clients.All.notification(notify);

        }
 public IHttpActionResult Upsert(NotifyEvent notify)
 {
     notify.New = true;
     notify.Created = DateTime.UtcNow;
     notify.Creator = User.Identity.Name;
     _notifier.Upsert(notify);
     return Ok(notify);
 }
Beispiel #3
0
 public bool ItHasSameContent(NotifyEvent other)
 {
     return(other.Title == Title && other.NotifyType == NotifyType && other.Description == Description);
 }
Beispiel #4
0
 public bool ItHasSameContent(NotifyEvent other)
 {
     return other.Title == Title && other.NotifyType == NotifyType && other.Description == Description;
 }