I am trying to grab values from my Cshtml to my HelperClass and then play with that data in my HomeController. I am trying to get my radio buttons data(value) and want to do summonerName as well but its the same concept. So if I could get help with one I could do the other. Now my interface can change to different methods etc. I am using Dependency Injection so I believe everything essentially runs through the interface. I am kinda lost so I could really use the help, thanks!

INTERFACE

   public interface IHomeHelper
{
    string getSummonerName(string summonerName);
    void getRegion(string region);
    string setSummonerName(string summonerName);
    void setRegion(string region);

}

HELPER CLASS

    public class HomeHelper : IHomeHelper
{
    public void getRegion(string region)
    {
        throw new NotImplementedException();
    }

    public string getSummonerName(string summonerName)
    {
        throw new NotImplementedException();
    }

    public void setRegion(string region)
    {
        throw new NotImplementedException();
    }

    public string setSummonerName(string summonerName)
    {
        throw new NotImplementedException();
    }
}

MODEL

public class HomeModel
{
    [Required]
    public string region { get; set; }
    [Required]
    [StringLength (255, MinimumLength = 5)]
    public string summonerName { get; set; }

}

CONTROLLER

    public class HomeController : Controller
{
    private readonly IHomeHelper _homeHelper;


    public HomeController(IHomeHelper homeHelper)
    {
        _homeHelper = homeHelper;

        if (ViewBag.region != null)
        {
            Console.WriteLine(ViewBag.region);
        }
    }

    public IActionResult Index()
    {


        return View();
    }

Index.cshtml FORM

  <form role="form" method="post">
   <div asp-validation-summary="ValidationSummary.ModelOnly"></div>
   <div class="col-md-12 form-group">
    <input type="search" size="100" id="mySearch" placeholder="Search for Summoner Name" asp-for="summonerName">
    <span asp-validation-for="summonerName"></span>
    <button type="submit" class="btn btn-primary "  formmethod="post">Search</button>
 </div>
 <div class="row">
  <div class="col-md-12 form-group">
  <label> NA</label>
 <input type="radio"  name ="region" id="NA" value="NA" asp-for="region" asp-items="ViewBag.region" />
  <span asp-validation-for="region"></span>
   <label>EUW</label>
  <input type="radio" name="region" id="EUW" value="EUW" asp-for="region" asp-items="ViewBag.region">
    <span asp-validation-for="region"></span>
                            </div>
                        </div>
                    </form>

Related posts

Recent Viewed