@{
    ViewData["Title"] = "View Expert Advisors";
    Layout = "~/Views/Shared/_GuruLayout.cshtml";
}

@model EForT.Models.AutoTradingModel

@using (Html.BeginForm("ViewExpertAdvisors", "ExpertAdvisor", FormMethod.Post, Model.ForexExpertAdvisorList))
{
<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">View Expert Advisors</h1>
            <div class="row breadcrumbs-top">
                <div class="breadcrumb-wrapper col-12">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item">
                            <a href="@Url.Action("Guru", "Home")">Home</a>
                        </li>
                        <li class="breadcrumb-item">
                            Expert Advisors
                        </li>
                        <li class="breadcrumb-item active">
                            View Expert Advisors
                        </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>Expert Advisors List</p>
                            </div>
                            <div class="heading-elements">
                                <a href="@Url.Action("AddExpertAdvisor", "ExpertAdvisor")" class="btn btn-sm btn-icon btn-primary">Add Expert Advisor</a>
                            </div>
                        </div>
                        <div class="card-body pt-2">
                            <div class="table-responsive">
                                <table id="users-list" class="table table-striped table-bordered">
                                    <thead>
                                        <tr>
                                            <th scope="col" style="width:20%; min-width:150px;">Name</th>
                                            <th scope="col" style="width:20%; min-width:150px;">Expert Name</th>
                                            <th scope="col" style="width:30%; min-width:150px;">Expert Parameters</th>
                                            <th scope="col" style="width:10%" class="text-center">Enabled</th>
                                            <th scope="col" style="width:10%" class="text-center">Edit</th>
                                            <th scope="col" style="width:10%" class="text-center">Delete</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @if (Model.ForexExpertAdvisorList != null)
                                            {
                                                if (Model.ForexExpertAdvisorList.Count > 0)
                                                {
                                        @for (int i = 0; i < Model.ForexExpertAdvisorList.Count; i++)
                                                    {
                                        <tr>
                                            <td>@Model.ForexExpertAdvisorList[i].Name</td>
                                            <td>@Model.ForexExpertAdvisorList[i].ExpertName</td>
                                            <td>@Model.ForexExpertAdvisorList[i].ExpertParameters</td>
                                            <td class="text-center">
                                                <label class="switch display-inline-block mb-0">
                                                    <input type="checkbox" asp-for="@Model.ForexExpertAdvisorList[i].Enabled" id="@Model.ForexExpertAdvisorList[i].Id" class="checkbox_expert">
                                                    <span class="slider round"></span>
                                                </label>
                                            </td>
                                            <td class="text-center">
                                                <a href="@Url.Action("EditExpertAdvisor", "ExpertAdvisor", new { Id = Model.ForexExpertAdvisorList[i].Id })" title="Edit EA" class="btn btn-icon btn-pure secondary"><i class="fa fa-pencil"></i></a>
                                            </td>
                                            <td class="text-center">
                                                <a href="@Url.Action("DeleteExpertAdvisor", "ExpertAdvisor", new { Id = Model.ForexExpertAdvisorList[i].Id })" onclick="return confirm('Are you sure you want to delete the expert advisor?')" title="Delete EA" class="btn btn-icon btn-pure danger"><i class="fa fa-trash"></i></a>
                                            </td>
                                        </tr>
                                                    }
                                                }
                                                else
                                                {
                                        <tr>
                                            <td colspan="5" class="danger text-center">No Expert Advisors in the system</td>
                                        </tr>
                                                }
                                            }
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
}

