public void RegisterQueueItemProgress(QueueEventType eventType, QueueItemDTO latestItem) { QueueEventLogDTO eventLogItem = new QueueEventLogDTO { Message = string.Format("Queue Data Item {0} is {1}", latestItem.BadgeAwardId, eventType.ToString()), QueueEventCreated = DateTime.Now, QueueEventId = (int)eventType, BadgeAwardId = latestItem.BadgeAwardId }; _queueEventLogDAL.Add(eventLogItem); }
public QueueItemDTO Add(QueueItemDTO item) { using (Entities context = new Entities()) { QueueItem addedItem = context.QueueItems.Add(new QueueItem { BadgeAwardId = item.BadgeAwardId, QueueItemCreated = DateTime.Now }); context.SaveChanges(); return new QueueItemDTO(addedItem.QueueItemId, addedItem.BadgeAwardId, addedItem.QueueItemCreated); } }
public void TestAdd() { ExecuteWithTransaction(() => { IQueueItemDAL queueItemDAL = IoC.Container.Resolve<IQueueItemDAL>(); QueueItemDTO queueItem = new QueueItemDTO { BadgeAwardId = 1 }; QueueItemDTO addedItem = queueItemDAL.Add(queueItem); Assert.IsTrue(addedItem.QueueItemId > 0); }); }
public QueueItemDTO Update(QueueItemDTO item) { using (Entities context = new Entities()) { QueueItem itemToUpdate = new QueueItem { QueueItemId = item.QueueItemId, BadgeAwardId = item.BadgeAwardId, QueueItemCreated = item.QueueItemCreated }; context.QueueItems.Attach(itemToUpdate); context.Entry(itemToUpdate).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return Get(item.QueueItemId); } }
public void ProcessItem(QueueItemDTO latestItem) { try { EarnedBadgeItemDTO earnedBadge = _earnedBadgeDAL.GetEarnedBadge(latestItem.BadgeAwardId); RegisterQueueItemProgress(QueueEventType.Processing, latestItem); PublishUpdates(earnedBadge); _queueItemDAL.Delete(latestItem.QueueItemId); RegisterQueueItemProgress(QueueEventType.Processed, latestItem); } catch { RegisterQueueItemProgress(QueueEventType.Failed, latestItem); throw; } }