public ServiceResult <JObject> ApiAddress(ApiAddressModel model) { var addressStr = ConfigurationManager.AppSettings.Get("ApiAddress"); var result = new ServiceResult <JObject> { Data = JsonConvert.DeserializeObject <JObject>(addressStr) }; result.Success(); return(result); }
public async Task <ActionResult <ListOfAddresesWithCountModel> > AddressesFetch(UserApiModel inputModel) { var currentUser = await this._usersService .GetUserByIdAsync(inputModel.Id); if (currentUser == null) { _logger.LogWarning($"Get current user from DB - NOT FOUND"); return(this.NotFound()); } var count = _addressesService .CountOfAddressesPerUser(currentUser); var listModel = new ListOfAddresesWithCountModel(); listModel.CountOfAddresses = count; var addressesPerUser = _addressesService .ListOfAddressesByUser(currentUser.UserName); if (addressesPerUser == null) { _logger.LogWarning($"Get list of addresses for user {currentUser.Id} from DB - NOT FOUND"); return(this.NotFound()); } if (addressesPerUser.Count() > 0) { foreach (var address in addressesPerUser) { var shortAddress = new ApiAddressModel { Id = address.Id, Country = address.Country, Region = address.Region, Town = address.Town, StreetName = address.StreetName, Number = address.Number, AddressType = address.AddressType.Value }; listModel.ListOfAdresses.Add(shortAddress); } } return(listModel); }