public async Task <short> Add(MimeType mimeType) { var mimeTypeDo = await messageQueueContext.tMimeTypes.SingleOrDefaultAsync(q => q.Expression == mimeType.Expression); var now = SystemClock.Instance.GetCurrentInstant().InUtc().ToDateTimeUtc(); if (mimeTypeDo != null) { mimeTypeDo.Changed = now; await messageQueueContext.SaveChangesAsync(); return(mimeTypeDo.MimeTypeId); } mimeTypeDo = new tMimeType { Expression = mimeType.Expression, Changed = now, Added = now }; await messageQueueContext.AddAsync(mimeTypeDo); await messageQueueContext.SaveChangesAsync(); mimeTypeDo = await messageQueueContext.tMimeTypes.SingleOrDefaultAsync(q => q.Expression == mimeType.Expression); return(mimeTypeDo.MimeTypeId); }
public async Task <short> Update(Queue queue) { var now = SystemClock.Instance.GetCurrentInstant().InUtc().ToDateTimeUtc(); tQueue queueDo = await messageQueueContext.tQueues.SingleOrDefaultAsync(q => q.Name == queue.Name); queueDo.Changed = now; await messageQueueContext.SaveChangesAsync(); return(queueDo.QueueId); }
public async Task <int> Update(Cursor cursor) { var now = SystemClock.Instance.GetCurrentInstant().InUtc().ToDateTimeUtc(); tCursor cursorDo = await messageQueueContext.tCursors.SingleOrDefaultAsync(q => q.CursorId == cursor.Id); cursorDo.Changed = now; cursorDo.NextReferenceId = cursor.NextAddress; await messageQueueContext.SaveChangesAsync(); return(cursorDo.CursorId); }