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

<h2>@ViewData["Title"]</h2>
<p class="text-success">@ViewData["StatusMessage"]</p>
<div>
    <h4>@SR["Change your account settings"]</h4>
    <hr />
    <dl class="dl-horizontal">
        <dt>@SR["UserName"]:</dt>
      
        <dd> 
            @Model.UserName
            [<a asp-controller="Manage" 
            asp-action="CHUN">@SR["Change"]</a>]
        </dd>

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

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

        <dt>@SR["Full name"]:</dt>
        <dd>@Model.FullName  [<a asp-controller="Manage" asp-action="SetFullName"
            >@SR[@Model.FullName==null?"Set":"Modify"]</a>]</dd>

        <dt>@SR["Address"]:</dt>
        <dd>@Model.PostalAddress
            [<a asp-controller="Manage" asp-action="SetAddress"
            >@SR[@Model.PostalAddress==null?"Set":"Modify"]</a>]
        </dd>
        
        <dt>@SR["Avatar"]:</dt>
        <dd>
            
            @Component.Invoke("Avatar", User.GetUserId(), ".s")
            [<a asp-controller="Manage" asp-action="SetAvatar"
            >@SR["Modify"]</a>]
        </dd> 

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

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

        <dt><a asp-controller="Blogspot" asp-action="UserPosts" 
            asp-route-id="@Model.UserName">@SR["Your posts"]:</a></dt>
        <dd>@Model.PostsCounter</dd>
       
      <dt>@SR["TwoFactorAuthentication"]:</dt> 
      <dd>
         @if (Model.TwoFactor)
         {
            using (Html.BeginForm("DisableTwoFactorAuthentication", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
            {
               @Html.AntiForgeryToken()
               <text>@SR["Enabled"]
                  <input type="submit" value="[@SR["Disable"]]" class="btn btn-link" />
               </text>
            }
         }
         else
         {
            using (Html.BeginForm("EnableTwoFactorAuthentication", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
            {
               @Html.AntiForgeryToken()
               <text>@SR["Disabled"]
                  <input type="submit" value="[@SR["Enable"]]" class="btn btn-link" />
               </text>
            }
         }
      </dd>
       <dt>@SR["Calendar"]</dt> 
      <dd> 
          @SR[Model.HasDedicatedCalendar?"Yes":"No"]
              [<a asp-action="SetGoogleCalendar">@SR["Select a Google calendar"]</a>]
      </dd>
       <dt>Credits:</dt> 
      <dd> 
          @(Model.Balance?.Credits ?? 0) &euro;
              [<a asp-action="Credits">@SR["Manage"]</a>]
      </dd>
      <dt>Usage disque</dt>
      <dd>
          @if (Model.DiskQuota>0)
          {
            <text>
                @((Model.DiskUsage/Model.DiskQuota).ToString("%#0")) : 
            </text>
          } 
          <text>
          @(Model.DiskUsage.ToString("0,#")) / @(Model.DiskQuota.ToString("0,#"))
          </text>
      </dd>
      <dt>Identifiant utilisateur</dt>
      <dd>
          @User.GetUserId()
      </dd>
    </dl>
    <h4>
      <a asp-controller="Account" asp-action="Delete" >@SR["Unregister"]</a>
    </h4>
</div>
