Beispiel #1
0
        public async Task <IActionResult> Add(string name)
        {
            {
                short?queueId = await queueRepository.Find(name);

                if (queueId.HasValue)
                {
                    return(Redirect("/list/{queueId}"));
                }
            }
            {
                short queueId = await queueRepository.Add(new Queue(name));

                return(Created($"/list/{queueId}", queueId));
            }
        }
        public Queue UpdateQueue(string id, QueueViewModel request)
        {
            Guid entityId = new Guid(id);

            var existingQueue = _queueRepo.GetOne(entityId);

            if (existingQueue == null)
            {
                throw new EntityDoesNotExistException("Queue could not be found");
            }

            var queue = _queueRepo.Find(null, d => d.Name.ToLower(null) == request.Name.ToLower(null) && d.Id != entityId)?.Items?.FirstOrDefault();

            if (queue != null && existingQueue.Id != entityId)
            {
                throw new EntityAlreadyExistsException("Queue already exists with same name");
            }

            existingQueue.Description   = request.Description;
            existingQueue.Name          = request.Name;
            existingQueue.MaxRetryCount = request.MaxRetryCount;

            return(existingQueue);
        }