Пример #1
0
        public async Task <IActionResult> CreateStore(StoreUpsertInput input)
        {
            _logger.LogInformation("Creating a store", input);
            var persistedStore = await _storeRepository.Insert(input.Name);

            return(Created($"/stores/{persistedStore.Id}", persistedStore.Convert()));
        }
Пример #2
0
        public async Task <IActionResult> UpdateStore(int id, StoreUpsertInput input)
        {
            _logger.LogInformation("Updating a store", input);

            try
            {
                var store = await _storeRepository.Update(id, input.Name, input.Address, input.Region);

                return(Accepted(store.Convert()));
            }
            catch (NotFoundException)
            {
                return(NotFound());
            }
        }
Пример #3
0
        public async Task <IActionResult> updateStore(int Id, StoreUpsertInput store)
        {
            // Code that checks if the given address exists
            var addresses = await _basisRegisterService
                            .AddressMatchAsync(store.Region, null, null, null, null, store.Address, store.StreetNumber, null, null);

            addresses.Warnings.ToList().ForEach(x => _logger.LogWarning($"{x.Code} {x.Message}"));
            if (!addresses.Warnings.Any())
            {
                // Code that updates a store.
                _logger.LogInformation("Updating a store", store);
                var persistedStore = await _storesRepository.Update(store.Id, store.Name, store.Address, store.StreetNumber, store.Region);

                return(Accepted());
            }
            else
            {
                return(Ok("The given address does not exist!"));
            }
        }