public async Task <IWriterResult> DeleteQueue(string adminUserId, SupportQueueModel model) { if (model.IsDefaultQueue) { return(new WriterResult(false, $"Cannot Delete Default Queue")); } using (var context = DataContextFactory.CreateContext()) { var projection = await context.SupportTicketQueue.Where(q => q.Id == model.Id) .Select(q => new { Queue = q, HasOpenTickets = q.Tickets.Any(t => t.Status != SupportTicketStatus.Closed) }).FirstNoLockAsync().ConfigureAwait(false); if (projection.HasOpenTickets) { return(new WriterResult(false, $"Cannot Delete Queue with open tickets")); } projection.Queue.IsDeleted = true; context.LogActivity(adminUserId, $"Queue closed: {model.Name}"); await context.SaveChangesAsync().ConfigureAwait(false); return(new WriterResult(true, $"Queue Deleted")); } }
public async Task <IWriterResult> UpdateQueue(SupportQueueModel model) { using (var context = DataContextFactory.CreateContext()) { var queue = await context.SupportTicketQueue.Where(q => q.Id == model.Id).FirstNoLockAsync().ConfigureAwait(false); queue.Name = model.Name; queue.Order = model.Order; await context.SaveChangesAsync().ConfigureAwait(false); return(new WriterResult(true, $"Queue Updated")); } }
public async Task <ActionResult> DeleteQueue(SupportQueueModel model) { var result = await QueueWriter.DeleteQueue(User.Identity.GetUserId(), model); return(Json(result)); }
public async Task <ActionResult> UpdateQueue(SupportQueueModel model) { var result = await QueueWriter.UpdateQueue(model); return(Json(result)); }