﻿@model GuestbookViewModel
@{
    ViewData["Title"] = "Home Page";
}

<div class="text-center">
    @using (Html.BeginForm("AddPost", "Home", FormMethod.Post))
    {
        <div class="form-group row">
            <label for="name" class="col-sm-2 col-form-label">Username</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="username" name="username">
            </div>
        </div>

        <div class="form-group row">
            <label for="posttext" class="col-sm-2 col-form-label">Text</label>
            <div class="col-sm-10">
                <textarea id="posttext" name="posttext" class="form-control"></textarea>
            </div>
        </div>

        <div>
            <button type="submit" class="btn btn-primary">Post</button>
        </div>
    }

    <div id="posts">
        @foreach (var post in Model.AllPosts)
        {
            <div><p><b>@post.Username</b> posted on @post.CreatedOn.ToString("yyyy-MM-dd hh:mm:ss")</p></div>
            <div>@post.Posttext</div>
        }
    </div>
</div>
