@{
    ViewData["Title"] = "My Forex Accounts";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@model EForT.Models.Legacy.ForexAccountModel

@using (Html.BeginForm("MyForexAccounts", "RegisteredUser", FormMethod.Post, Model.ForexAccountList))
{
    <div class="app-content container center-layout py-3">
        <div class="content-header row">
            <div class="content-header-left col-12 mb-2">
                <h1 class="content-header-title mb-0">My Forex Accounts</h1>
                <div class="row breadcrumbs-top">
                    <div class="breadcrumb-wrapper col-12">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item">
                                <a href="@Url.Action("Index", "RegisteredUser")">Home</a>
                            </li>
                            <li class="breadcrumb-item active">
                                My Forex Accounts
                            </li>
                        </ol>
                    </div>
                </div>
            </div>
        </div>
        <div class="content-wrapper">
            <div class="content-body">
                <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-header pb-0">
                                <div class="font-medium-2 bottom-border">
                                    <p>Linked Accounts</p>
                                </div>
                            </div>
                            <div class="card-body pt-0">
                                <div id="forex-list-table" class="table-responsive">
                                    <table id="forex-list" class="table table-bordered table-striped">
                                        <thead>
                                            <tr>
                                                <th scope="col" style="width:40%; min-width:200px;">Login</th>
                                                <th scope="col" style="width:40%; min-width:200px;">Server</th>
                                                <th scope="col" style="width:10%" class="text-center">Edit</th>
                                                <th scope="col" style="width:10%" class="text-center">Unlink</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            @if (Model.ForexAccountList != null)
                                            {
                                                if (Model.ForexAccountList.Count > 0)
                                                {
                                                    for (int i = 0; i < Model.ForexAccountList.Count; i++)
                                                    {
                                                        <tr>
                                                            <td>@Model.ForexAccountList[i].Login</td>
                                                            <td>@Model.ForexAccountList[i].ServerName</td>
                                                            <td class="text-center">
                                                                <a href="@Url.Action("EditForexAccount", "RegisteredUser", new { forexId = Model.ForexAccountList[i].ForexId })" title="Edit Account" class="btn btn-icon btn-pure secondary"><i class="fa fa-pencil"></i></a>
                                                            </td>
                                                            <td class="text-center">
                                                                <a href="@Url.Action("DeleteForexAccount", "RegisteredUser", new { forexId = Model.ForexAccountList[i].ForexId })" onclick="return confirm('Are you sure you want to unlink the account?')" title="Unlink Account" class="btn btn-icon btn-pure danger"><i class="fa fa-trash"></i></a>
                                                            </td>
                                                        </tr>
                                                    }
                                                }
                                                else
                                                {
                                                    <tr class="even"><td valign="top" colspan="4" class="dataTables_empty text-center">No accounts linked</td></tr>
                                                }
                                            }
                                        </tbody>
                                    </table>
                                </div>
                                <div class="row pt-2">
                                    <div class="px-1">
                                        <a href="@Url.Action("AddForexAccount", "RegisteredUser")" class="btn btn-primary">Add New Account </a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
}