using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using KsiegaGosci.Models;

namespace KsiegaGosci.Controllers
{
    public class GuestBookController : Controller
    {
        //
        // GET: /GuestBook/

        //test: http://localhost:1518/GuestBook

        Wpisy wpisy = new Wpisy();

        public ActionResult Index()
        {
            return View();
        }

        //stworzone
        [HttpPost]
        public ActionResult Index(FormCollection formularz)
        {
            string userName = formularz["nazwa_użytkownika"];
            string contentText = formularz["treść_wpisu"];

            Wpis wpis = new Wpis(userName, contentText, DateTime.Now, Request.UserHostAddress);
            wpisy.Add(wpis);

            ViewBag.wpisy = wpisy;

            return View();
        }
    }
}
