@model IndexViewModel
@using System.Security.Claims
@{
    ViewData["Title"] = "Manage your account";
}

<h2>@ViewData["Title"]</h2>
<p class="text-success">@ViewData["StatusMessage"]</p>
<div>
    <h4>Your account settings</h4>
    <hr />
    <dl class="dl-horizontal">
        <dt>UserName:</dt>
      
        <dd> 
            @Model.UserName
            <a asp-action="SetUserName">[modifier]</a>
        </dd>

        <dt>E-mail</dt>
      
        <dd> 
            @Model.EMail

            @if (Model.EmailConfirmed) {
                <text>(Adresse E-mail confirmée)</text>
            } else {
                <text>
                  <i>  (Adresse non confirmée.)</i>
            <form asp-action="SendConfirationEmail" asp-controller="Account" enctype="multipart/form-data">
                <input type="submit" value="Confirmer cette adresse"]"/>
            </form>
                </text>
            }
        </dd>

        <dd>
            <dl>
                <dt>Allow Monthly Email</dt>
                <dd>
                    <a asp-action="ProfileEMailUsage"> @Html.DisplayFor(m=>m.AllowMonthlyEmail) [modifier]
                    </a>
                </dd>
            </dl>
        </dd>


        <dt>FullName:</dt>
        <dd> 
            @Html.DisplayFor(m=>m.FullName) 
             <a asp-action="SetFullName">[modifier]</a>
        </dd>

        @if (Model.Roles.Count()>0) {
        <dt>Roles:</dt>
        <dd> 
            @string.Join(", ",Model.Roles)
        </dd>}
        <dt>Password:</dt>
        <dd>[@{if (Model.HasPassword)
            {<a asp-controller="Manage" 
            asp-action="ChangePassword">Change</a>}
            else
            {<a asp-controller="Manage" 
            asp-action="SetPassword">Create</a>}}]</dd>

        <dt>External Logins:</dt>
        <dd>
            @Model.Logins.Count [<a asp-controller="Manage" asp-action="ManageLogins">Manage</a>]
        </dd>

        <dt>Address:</dt>
        <dd>@Model.PostalAddress
            [<a asp-controller="Manage" asp-action="SetAddress">
            @{ if (Model.PostalAddress==null)
            {
                Html.DisplayText("Set");
            }
            else 
            {
Html.DisplayText("Modify");
            }
            }
            </a>]
        </dd>
        
        <dt>Avatar:</dt>
        <dd>
                   <img src="/Avatars/@(User.GetUserName()+".s").png" asp-append-version="true" class="smalltofhol" />
            [<a asp-controller="Manage" asp-action="SetAvatar">Modify</a>]
        </dd> 

        <dt>Vos cercles</dt>
        <dd> (WIP) <a asp-action="Index" asp-controller="Circle">Ajouter suprimer des cercles</a>
            <a asp-action="Index" asp-controller="CircleMembers">Gérer les membres de vos cercles</a>
        </dd>

        <dt>Professional settings:</dt>
        <dd>
            @Html.DisplayFor(model => model.HaveProfessionalSettings)
            [<a asp-controller="Manage" asp-action="SetActivity"
            >@(Model.HaveProfessionalSettings?"Modify settings":"Set")</a>]
        </dd>
@if (Model.HaveProfessionalSettings) {
        <dt>Activities:</dt>
        <dd>
           @string.Join(", ",Model.Activity.Select( u=> u.Does.Name ).ToArray())
            [<a asp-controller="Do" asp-action="Index"
            >@(Model.Activity==null?"Set":"Modify settings")</a>]
        </dd>
}
        <dt>Bank info:</dt>
        <dd>@Html.DisplayFor(m => m.BankInfo)  [<a asp-controller="Manage" asp-action="AddBankInfo"
            >@(Model.BankInfo==null?"Set":"Modify")</a>]</dd>

        <dt><a href="/Blog/@Model.UserName">Your posts:</a></dt>
        <dd>@Model.PostsCounter</dd>
       
      <dt>TwoFactorAuthentication:</dt> 
      <dd>
         @if (Model.TwoFactor)
         {
            using (Html.BeginForm("DisableTwoFactorAuthentication", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
            {
               @Html.AntiForgeryToken()
               <text>Enabled
                  <input type="submit" value="[Disable"]]" class="btn btn-link" />
               </text>
            }
         }
         else
         {
            using (Html.BeginForm("EnableTwoFactorAuthentication", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
            {
               @Html.AntiForgeryToken()
               <text>Disabled
                  <input type="submit" value="[Enable"]]" class="btn btn-link" />
               </text>
            }
         }
      </dd>
       <dt>Calendar</dt> 
      <dd> 
          @Html.DisplayText(Model.HasDedicatedCalendar?"Yes":"No" )
          @{
            if (Model.HasDedicatedCalendar) { 
             <text> : @Model.DedicatedCalendarId </text>
          }
          }
        [<a asp-action="SetGoogleCalendar">Select a Google calendar</a>]
      </dd>
      <environment names="Development">
       <dt>Credits:</dt> 
      <dd> 
          @(Model.Balance?.Credits ?? 0) &euro;
              [<a asp-action="Credits">Manage</a>]
      </dd>
      </environment>

      <dt>Usage disque</dt>
      <dd>
          @if (Model.DiskQuota>0)
          {
            <text>
                @(((double)Model.DiskUsage/Model.DiskQuota).ToString("%#0")) : 
            </text>
          } 
          <code>
          @(Model.DiskUsage.ToString("0,#")) / @(Model.DiskQuota.ToString("0,#"))
          </code>
      </dd>
      <dt>Identifiant utilisateur</dt>
      <dd>
          @User.GetUserId()
      </dd>
    </dl>
    <h4>
      <a asp-controller="Account" asp-action="Delete" >Unregister</a>
    </h4>
</div>
