Beispiel #1
0
        public async Task <IActionResult> Calculate(Guid guid)
        {
            var block = hostRepository.GetByGuid(guid);

            if (block == null)
            {
                return(NotFound($"Block with guid {guid} not found"));
            }

            var result = await SendCalculationRequest(guid);

            return(Ok($"The results are: {string.Join(", ", result)}"));
        }
Beispiel #2
0
        public IActionResult Calculate(Guid guid)
        {
            var block = localRepository.GetByGuid(guid);

            // If Block doesn't exist in local container's volume, try getting it from the main repo ("~/docker_microservices/db" directory on host machine)
            if (block == null)
            {
                block = hostRepository.GetByGuid(guid) ?? throw new Exception($"Block doesn't exist in any repository");
                localRepository.Add(block);
            }

            return(Ok(block.Requests.Select(req => req.FirstValue + req.SecondValue)));
        }