Webiant Logo Webiant Logo
  1. No results found.

    Try your search with a different keyword or use * as a wildcard.

What3wordsCountryController.cs

using Microsoft.AspNetCore.Mvc;
using Nop.Services.Directory;
using Nop.Web.Controllers;

namespace Nop.Plugin.Widgets.What3words.Controllers;

[AutoValidateAntiforgeryToken]
public class What3wordsCountryController : BasePublicController
{
    #region Fields

    protected readonly ICountryService _countryService;

    #endregion

    #region Ctor

    public What3wordsCountryController(ICountryService countryService)
    {
        _countryService = countryService;
    }

    #endregion

    #region Methods

    public async Task GetAlpha2byCountryName(int countryId)
    {
        var result = (await _countryService.GetCountryByIdAsync(countryId))?.TwoLetterIsoCode;
        return Json(result);
    }

    #endregion
}