@model MileageTraker.Web.Models.User

@{
    ViewBag.Title = "User Details";
}

@{ Html.RenderPartial("BackToUsers"); }

@Html.Partial("_StatusMessage")

<h2 class="center-content">@ViewBag.Title</h2>

<div class="center-content well">
    
    @Html.DisplayFor(m => m.FullName)
    
    <dl class="dl-horizontal username">
        <dt>
            @Html.DisplayNameFor(m => m.Username)
        </dt>
        <dd>
            @Html.Encode(Model.Username)
            @Html.Partial("_UserStatusLabels")
        </dd>
    </dl>

    @Html.DisplayFor(m => m.Email)

    <dl class="dl-horizontal roles">
        <dt>
            @Html.DisplayNameFor(m => m.Roles)
        </dt>
        <dd>
            @{ var roles = Roles.Provider.GetRolesForUser(Model.Username); }
            @if (roles.Length > 0)
            {
                @Html.Encode(string.Join(", ", roles))
            }
            else
            {
                <span class='label label-warning'>No Role</span>
            }
        </dd>
    </dl>

    <dl class="dl-horizontal lastActivityDate">
        <dt>
            @Html.DisplayNameFor(m => m.LastActivityDate)
        </dt>
        <dd>
            @Html.Partial("_DateTimeHistoric",
                new Tuple<DateTime,string>(Model.LastActivityDate, "No Activity"))
        </dd>
    </dl>
    
    <dl class="dl-horizontal lastLoginDate">
        <dt>
            @Html.DisplayNameFor(m => m.LastLoginDate)
        </dt>
        <dd>
            @Html.Partial("_DateTimeHistoric",
                new Tuple<DateTime,string>(Model.LastLoginDate, "Never Logged In"))
        </dd>
    </dl>

    <dl class="dl-horizontal lastPasswordChangedDate">
        <dt>
            @Html.DisplayNameFor(m => m.LastPasswordChangedDate)
        </dt>
        <dd>
            @Html.Partial("_DateTimeHistoric",
                new Tuple<DateTime,string>(Model.LastPasswordChangedDate, "Never Changed"))
        </dd>
    </dl>
    
    @if (Model.IsLockedOut) {
        <dl class="dl-horizontal lastLockoutDate">
            <dt>
                Lockout Password Date
            </dt>
            <dd>
                @Html.Partial("_DateTimeHistoric",
                    new Tuple<DateTime,string>(Model.LastLockoutDate, "Never Locked (?)"))
            </dd>
        </dl>
    }
</div>

<div class="btn-toolbar center-content">
    @Html.ActionLink("Edit", "Edit", new { id = Model.UserId }, new { @class = "btn" })
    <div class="btn-group">
        <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
            Password <span class="caret"></span>
        </a>
        <ul class="dropdown-menu">
            <li>
                @Html.ActionLink("Send Password Reset Email", "SendResetPassword", new { userId = Model.UserId })
            </li>
            <li>
                @Html.ActionLink("Set Password", "SetPassword", new { id = Model.UserId })
            </li>
        </ul>
    </div>
    @if (Model.IsApproved)
    {
        @Html.ActionLink("Disable Account", "DisableUser", new {id = Model.UserId}, new {@class = "btn"})
    }
    else
    {
        @Html.ActionLink("Enable Account", "EnableUser", new {id = Model.UserId}, new {@class = "btn"})
    }
    @if (Model.IsLockedOut)
    {
        @Html.ActionLink("Unlock", "UnlockUser", new {id = Model.UserId}, new {@class = "btn"})
    }
</div>
