using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace ASPNETCore_NETCore.Pages.RazorPages
{
 public class IndexMitCodeBehindModel : PageModel
 {

  IHostingEnvironment env;
  public IndexMitCodeBehindModel(IHostingEnvironment env)
  {
   this.env = env;
  }
  public string Meldung { get; set; }
  //public void OnGet()
  //{
  // this.Meldung += "OnGet<br>";
  //}

  public void OnGetAlle()
  {
   this.Meldung += "OnGetAlle<br>";
  }

  public void OnGetNurNeue()
  {
   this.Meldung += "OnGetNurNeue<br>";
  }

  // Groß-Klein-Schreibweise bewusst inkonsistent für demo!
  public void OnGetNuralte()
  {
   this.Meldung += "OnGetnuralte<br>";
  }

  [BindProperty]
  public string Name { get; set; }

  public IActionResult OnPost()
  {
   this.Meldung += "OnPost: " + this.Name + "<br>";
   return Page();
  }
  public IActionResult OnPostGutenTag()
  {
   this.Meldung += "OnPostGutenTag: " + this.Name + "<br>";
   return Page();
  }

  public IActionResult OnPostHallo()
  {
   this.Meldung += "OnPostHallo: " + this.Name + "<br>";

   return Page();
  }

  public IActionResult OnPostNotFound()
  {

   return NotFound();
  }

  public IActionResult OnPostForbidden()
  {

   return Unauthorized();
  }

  public IActionResult OnPostGetFile()
  {

   var webRoot = env.WebRootPath;
   var path = System.IO.Path.Combine(webRoot, "Download/www.IT-Visions.de_Flyer_Webfassung.pdf");

   return PhysicalFile(path, "application/pdf");
  }


  //public async Task OnGetAsync()
  //{
  // this.Meldung += "OnGetAsync<br>";
  //}
  //public async Task<IActionResult> OnPostAsync()
  //{
  // this.Meldung += "OnPostAsync: " + this.Name + "<br>";
  // await Task.Delay(1);
  // return Page();
  //}
 }
}