public IActionResult Index()
        {
            var user = HttpContext.User as User;

            List <Product> products = null;

            if (UserRoleHelper.IsProductCRUDAllowed(user))
            {
                products = _productManager.Products;
            }
            else
            {
                products = _productManager.GetProducts(user);
            }

            products = products?.OrderBy(x => x.Name).ToList();

            var result = products?.Select(x => new ProductViewModel(
                                              _userManager.GetManagers(x.Key).FirstOrDefault()?.UserName ?? "---", x)).ToList();

            return(View(result));
        }
        public static string CreateTable(User user, List <ProductViewModel> products)
        {
            StringBuilder result = new StringBuilder();

            //header template
            result.Append("<div style='margin: 10px'>" +
                          "<div class='row justify-content-start'><div class='col-2'>" +
                          "<h5 style='margin: 10px 20px 10px;'>Products</h5></div></div></div>");


            result.Append("<div class='col-xxl'>");
            //table template
            result.Append("<table class='table table-striped'><thead><tr>" +
                          "<th scope='col'>#</th>" +
                          "<th scope='col'>Name</th>" +
                          "<th scope='col'>Key</th>" +
                          "<th scope='col'>Creation Date</th>" +
                          "<th scope='col'>Manager</th>");

            if (UserRoleHelper.IsProductCRUDAllowed(user) ||
                ProductRoleHelper.IsProductActionAllowed(user.ProductsRoles))
            {
                result.Append("<th scope='col'>Action</th></tr>");
            }

            result.Append("</thead><tbody>");

            //create
            if (UserRoleHelper.IsProductCRUDAllowed(user))
            {
                result.Append("<tr><th>0</th>" +
                              "<th><input id='createName' type='text' class='form-control'/>" +
                              "<span style='display: none;' id='new_product_name_span'></th>" +
                              "<th>---</th>" +
                              $"<th>---</th>" +
                              $"<th>---</th>" +
                              "<th><button id='createButton' style='margin-left: 5px' type='button' class='btn btn-secondary' title='create'>" +
                              $"<i class='fas fa-plus'></i></button></th></tr>");
            }

            if (products == null || products.Count == 0)
            {
                return(result.ToString());
            }

            int index = 1;

            foreach (var product in products)
            {
                result.Append($"<tr><th scope='row'>{index}</th>" +
                              $"<td>{product.Name}</td>" +
                              $"<td id='key_{product.Key}' value='{product.Key}'>{product.Key} " +
                              $"<button id='copy_{product.Key}' data-clipboard-text='{product.Key}' title='copy key' type='button' class='btn btn-secondary'>" +
                              $"<i class='far fa-copy'></i></button>" +
                              $"<input style='display: none' type='text' id='inputName_{product.Key}' value='{product.Name}'/></td>" +
                              $"<td>{product.CreationDate}</td>" +
                              $"<td>{product.ManagerName}</td>");


                if (UserRoleHelper.IsProductCRUDAllowed(user) ||
                    ProductRoleHelper.IsManager(product.Key, user.ProductsRoles))
                {
                    result.Append($"<td><button style='margin-left: 5px' id='change_{product.Key}' " +
                                  $"type='button' class='btn btn-secondary' title='edit'>" +
                                  "<i class='fas fa-edit'></i></button>");
                }

                if (UserRoleHelper.IsProductCRUDAllowed(user))
                {
                    result.Append($"<button id='delete_{product.Key}' style='margin-left: 5px' " +
                                  $"type='button' class='btn btn-secondary' title='delete'>" +
                                  $"<i class='fas fa-trash-alt'></i></button>");
                }

                result.Append("</tr>");
                index++;
            }

            result.Append("</tbody></table></div></div>");

            return(result.ToString());
        }