Пример #1
0
 internal static List<DrugCategory> GetAllDrugCategories()
 {
     var svc = new DrugCategoryAppService();
     return svc.GetAllDrugCategory();
 }
        public DataTablesResult<DrugCategoryViewModel> GetAllRecords(DataTablesParam dataTableParam)
        {

            var svc = new DrugCategoryAppService();
            var lst = svc.GetAllDrugCategory();
            var lstVm = new List<DrugCategoryViewModel>();
            foreach (var itm in lst)
            {

                var itmVm = new DrugCategoryViewModel
                {

                    Name = itm.Name,
                    DrugCategoryId= itm.DrugCategoryId,

                };

              




                var sb = new StringBuilder();

                string editUrl = Url.Action("Edit", "DrugCategory");
                sb.AppendLine("<div class=\"btn-group\">");
                sb.AppendLine(
                    "<button type=\"button\" class=\"btn btn-default dropdown-toggle\" data-toggle=\"dropdown\" aria-expanded=\"false\">");
                sb.AppendLine("Acciones <span class=\"caret\"></span>");
                sb.AppendLine("</button>");
                sb.AppendLine("<ul class=\"dropdown-menu\" role=\"menu\">");
                sb.AppendLine("<li><a href=\"" + editUrl + "?id=-1\"><i class=\"fa fa-plus\"></i>&nbsp;Nuevo Registro</a></li>");
                sb.AppendLine("<li><a href=\"" + editUrl + "?id=" + itmVm.DrugCategoryId+ "\"><i class=\"fa fa-edit\"></i>&nbsp;Editar " + itmVm.Name + "</a></li>");
                sb.AppendLine("</ul>");
                sb.AppendLine("</div>");






                var actionButton = sb.ToString();

                itmVm.ActionButton = actionButton;
                lstVm.Add(itmVm);

            }

            var lstVmQueryable = lstVm.AsQueryable();


            return DataTablesResult.Create(lstVmQueryable, dataTableParam);

        }