public static List<Employee> GetAllEmployeeList()
 {
     var svc = new EmployeeAppService();
     return svc.GetAllEmployee();
 }
        public DataTablesResult<EmployeeViewModel> GetAllEmployees(DataTablesParam dataTableParam)
        {

            var svc = new EmployeeAppService();
            var users = svc.GetAllEmployee();
            var usersVm = new List<EmployeeViewModel>();
            var userRoleSvc = new UserRoleAppService();
            


            foreach (var itm in users)
            {

                var itmVm = new EmployeeViewModel
                {
                    FullName = itm.FullName,
                    UserName = itm.User.UserName,
                    EmployeeTypeName=itm.EmployeeType.Name,
                    Mobile = itm.Mobile,
                    UserStateName = itm.User.UserState.Description,
                    EMail = "<a title=\"Escribir a " + itm.FullName + "...\" target=\"_blank\" href=\"mailto:" + itm.EMail + "\"><i class=\"fa fa-envelope\"></i>&nbsp;" + itm.EMail + "</a>",
                    EmployeeId = itm.EmployeeId,
                    EmployeeTypeId = itm.EmployeeTypeId,
                    UserId = itm.User.UserId,
                    Phone = itm.Phone,

                };
                var currentRoles = userRoleSvc.GetUserRoleByUserId(itm.UserId);
                foreach (var userRole in currentRoles)
                {
                    itmVm.RoleNames += userRole.Role.Name + ",";
                }

                itmVm.RoleNames = itmVm.RoleNames.Remove(itmVm.RoleNames.Length - 1);

                if (!System.IO.File.Exists(Server.MapPath("~/Employee_Files/" + itm.EmployeeId + "/")))
                {
                    Directory.CreateDirectory(Server.MapPath("~/Employee_Files/" + itm.EmployeeId + "/"));
                }
             

                

                if (itm.Photo != null)
                {
                    if (System.IO.File.Exists(Server.MapPath("~/Employee_Files/" + itm.EmployeeId + "/" + itm.Photo)))
                    {

                        byte[] image =
                            System.IO.File.ReadAllBytes(
                                Server.MapPath("~/Employee_Files/" + itm.EmployeeId + "/" + itm.Photo));
                        var base64 = Convert.ToBase64String(image);
                        var imgSrc = String.Format("data:image/png;base64,{0}", base64);
                        itmVm.PhotoEncodeSource = "<img src=\"" + imgSrc + "\" class=\"photo-table-image\"/>";
                    }
                    else
                    {
                        itmVm.PhotoEncodeSource = "Image Error";
                    }
                }

                var sb = new StringBuilder();

                string editUrl = Url.Action("Edit", "Employee");
                string specialtyUrl = Url.Action("Index", "MedicSpecialty");
                string officeUrl = Url.Action("Index", "Office");
                string scheduleUrl = Url.Action("Index", "Schedule");
                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 Empleado</a></li>");
                sb.AppendLine("<li><a href=\"" + editUrl + "?id=" + itmVm.EmployeeId + "\"><i class=\"fa fa-edit\"></i>&nbsp;Editar " + itmVm.FullName + "</a></li>");

                if (itmVm.EmployeeTypeId != 2) {
                    sb.AppendLine("<li><a href=\"" + specialtyUrl + "?id=" + itmVm.EmployeeId + "\"><i class=\"fa fa-edit\"></i>&nbsp;Especialidades " + itmVm.FullName + "</a></li>");
                sb.AppendLine("<li><a href=\"" + officeUrl + "?id=" + itmVm.EmployeeId + "\"><i class=\"fa fa-edit\"></i>&nbsp;Oficinas de " + itmVm.FullName + "</a></li>");
                sb.AppendLine("<li><a href=\"" + scheduleUrl + "?id=" + itmVm.EmployeeId + "\"><i class=\"fa fa-edit\"></i>&nbsp;Agenda de " + itmVm.FullName + "</a></li>");
                
                }

                sb.AppendLine("</ul>");
                sb.AppendLine("</div>");






                var actionButton = sb.ToString();

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

            }

            var usersVmQueryable = usersVm.AsQueryable();


            return DataTablesResult.Create(usersVmQueryable, dataTableParam);

        }