using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using TelerikAspNetCoreApp366.Data;

namespace TelerikAspNetCoreApp366.Pages
{
    public class IndexModel : PageModel
    {
        [BindProperty]
        public Contractor Contractor { get; set; }

        public void OnGet()
        {
            if(Contractor == null)
            {
                Contractor = new Contractor() { CompanyId = 3, ContractorId = 123, Name = "John Doe" };
                var data = Enumerable.Range(1, 5).Select(x => new
                {
                    Text = "Company " + x,
                    Id = x
                });
                ViewData["companies"] = data;
            }
        }

        public IActionResult OnPost()
        {
            var selectedContractor = Request.Form["Contractor"];

            return RedirectToPage("Success");
        }
    }
}
