public DataTablesResult GetUsersGridModel(DataTablesParam dataTableParam)
        {
            Contract.Assert(dataTableParam != null);
            Contract.Assert(dataTableParam.iDisplayLength != 0);

            var pageIndex = dataTableParam.iDisplayStart / dataTableParam.iDisplayLength;
            var queryData = new UserAll { PageIndex = pageIndex, PageSize = dataTableParam.iDisplayLength };

            var query = this.Manager.FindAll(queryData);
            var count = this.Manager.Count(queryData);

            var list = (from u in query
                        select new[] 
                                { 
                                    u.Id.ToString(CultureInfo.InvariantCulture),
                                    u.Name,
                                    u.Email,
                                    u.UserPasswordCredential != null ? u.UserPasswordCredential.Login : string.Empty
                                }).OfType<object>().ToArray();

            var result = new DataTablesResult
                {
                    JsonRequestBehavior = JsonRequestBehavior.DenyGet,
                    Data = new DataTablesData
                        {
                            iTotalRecords = dataTableParam.iDisplayLength,
                            iTotalDisplayRecords = count,
                            sEcho = dataTableParam.sEcho, 
                            aaData = list
                        }
                };

            return result;
        }
        public JsonResult GetUserData(DataTablesParam param)
        {
            var menuList = GetMenus();
            //开始记录
            int iDisplayStart = Convert.ToInt32(Request.Params["iDisplayStart"]);
            //单页显示记录数
            int iDisplayLength = Convert.ToInt32(Request.Params["iDisplayLength"]);
            var data = menuList.Skip(iDisplayStart).Take(iDisplayLength).Select(o => new 
            {
                Code = o.Code,
                CreateTime =o.CreateTime.ToShortDateString(),
                IconCls = "",
                ID = o.ID,
                Info = o.Info,
                Name = o.Name
            }).ToList();
            return Json(new 
            {
                sEcho = param.sEcho,
                iTotalRecords = menuList.Count(),
                iTotalDisplayRecords = menuList.Count(),//data.Count(),
                aaData = data
            }, JsonRequestBehavior.AllowGet);
            
            //var jsonStr = JsonConvert.SerializeObject(menuList);
            ////return "{'data':" + jsonStr + "}";
            //var result = "{\"data\": " + jsonStr + "}";

            //return result;
        }
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            var obj = new DataTablesParam();
            var request = controllerContext.HttpContext.Request.Params;

            obj.iDisplayStart = Convert.ToInt32(request["iDisplayStart"]);
            obj.iDisplayLength = Convert.ToInt32(request["iDisplayLength"]);
            obj.iColumns = Convert.ToInt32(request["iColumns"]);
            obj.sSearch = request["sSearch"];
            obj.bEscapeRegex = Convert.ToBoolean(request["bEscapeRegex"]);
            obj.iSortingCols = Convert.ToInt32(request["iSortingCols"]);
            obj.sEcho = int.Parse(request["sEcho"]);

            for (int i = 0; i < obj.iColumns; i++)
            {
                obj.bSortable.Add(Convert.ToBoolean(request["bSortable_" + i]));
                obj.bSearchable.Add(Convert.ToBoolean(request["bSearchable_" + i]));
                obj.sSearchColumns.Add(request["sSearch_" + i]);
                obj.bEscapeRegexColumns.Add(Convert.ToBoolean(request["bEscapeRegex_" + i]));
                obj.iSortCol.Add(Convert.ToInt32(request["iSortCol_" + i]));
                obj.sSortDir.Add(request["sSortDir_" + i]);
            }

            return obj;
        }
 public override int[] ExecuteParams(DataTablesParam dataTablesParam)
 {
     DataContext.Dispose(); //reset datacontext in order to clear local 
     DataContext = new SomeContext();
     int[] returnVar = base.ExecuteParams(dataTablesParam);
     Assert.AreEqual(returnVar.Length, DataContext.Models.Local.Count, "records loaded in memory");
     return returnVar;
 }
        // datatable test method
        public DataTablesResult<GridModel> GetList(DataTablesParam dataTableParam)
        {
            var articleList = _products.GetAll();

            var articleGridModels = articleList.Select(x => new GridModel() { Id = x.Id, Title = x.Name });

            return DataTablesResult.Create(articleGridModels, dataTableParam);
        }
Exemple #6
0
        public static DataTablesResult Create(IQueryable queryable, DataTablesParam dataTableParam)
        {
            var s = "Create";
            var openCreateMethod   = typeof(DataTablesResult).GetMethods().Single(x => x.Name == s && x.GetGenericArguments().Count() == 1);
            var queryableType      = queryable.GetType().GetGenericArguments()[0];
            var closedCreateMethod = openCreateMethod.MakeGenericMethod(queryableType);

            return((DataTablesResult)closedCreateMethod.Invoke(null, new object[] { queryable, dataTableParam }));
        }
 public virtual int[] ExecuteParamsAndTransform(DataTablesParam dataTablesParam)
 {
     var result = DataTablesResult.Create(SomeModelQueryable,
         dataTablesParam,
         m => new { 
             FriendlyWhen = m.When.ToShortDateString(),
         });
     var data = result.Data;
     return data.aaData.Select(d=>Convert.ToInt32(((IList)d)[0])).ToArray();
 }
Exemple #8
0
        /// <param name="transform">Should be a Func<T, TTransform></param>
        public static DataTablesResult Create(IQueryable queryable, DataTablesParam dataTableParam, object transform,
                                              ArrayOutputType?arrayOutput = null)
        {
            var s = "Create";
            var openCreateMethod   = typeof(DataTablesResult).GetMethods().Single(x => x.Name == s && x.GetGenericArguments().Count() == 2);
            var queryableType      = queryable.GetType().GetGenericArguments()[0];
            var transformType      = transform.GetType().GetGenericArguments()[1];
            var closedCreateMethod = openCreateMethod.MakeGenericMethod(queryableType, transformType);

            return((DataTablesResult)closedCreateMethod.Invoke(null, new object[] { queryable, dataTableParam, transform, arrayOutput }));
        }
 private DataTablesPropertyInfo FindColumn(DataTablesParam dtParameters, DataTablesPropertyInfo[] columns, int i)
 {
     if (dtParameters.sColumnNames.Any())
     {
         return(columns.First(x => x.PropertyInfo.Name == dtParameters.sColumnNames[i]));
     }
     else
     {
         return(columns[i]);
     }
 }
        public IQueryable FilterPagingSortingSearch(DataTablesParam dtParameters, IQueryable data, out int totalRecordsDisplay, Tuple <string, string, Type>[] columns)
        {
            if (!String.IsNullOrEmpty(dtParameters.sSearch))
            {
                var parts      = new List <string>();
                var parameters = new List <object>();
                for (var i = 0; i < dtParameters.iColumns; i++)
                {
                    if (dtParameters.bSearchable[i])
                    {
                        parts.Add(GetFilterClause(dtParameters.sSearch, columns[i], parameters));
                    }
                }
                data = data.Where(string.Join(" or ", parts), parameters.ToArray());
            }
            for (int i = 0; i < dtParameters.sSearchColumns.Count; i++)
            {
                if (dtParameters.bSearchable[i])
                {
                    var searchColumn = dtParameters.sSearchColumns[i];
                    if (!string.IsNullOrWhiteSpace(searchColumn))
                    {
                        var parameters   = new List <object>();
                        var filterClause = GetFilterClause(dtParameters.sSearchColumns[i], columns[i], parameters);
                        data = data.Where(filterClause, parameters.ToArray());
                    }
                }
            }
            string sortString = "";

            for (int i = 0; i < dtParameters.iSortingCols; i++)
            {
                int    columnNumber = dtParameters.iSortCol[i];
                string columnName   = columns[columnNumber].Item1;
                string sortDir      = dtParameters.sSortDir[i];
                if (i != 0)
                {
                    sortString += ", ";
                }
                sortString += columnName + " " + sortDir;
            }

            totalRecordsDisplay = data.Count();

            data = data.OrderBy(sortString);
            data = data.Skip(dtParameters.iDisplayStart);
            if (dtParameters.iDisplayLength > -1)
            {
                data = data.Take(dtParameters.iDisplayLength);
            }

            return(data);
        }
        public IQueryable FilterPagingSortingSearch(DataTablesParam DTParams, IQueryable data, out int totalRecordsDisplay, Tuple<string, Type>[] columns)
        {

            if (!String.IsNullOrEmpty(DTParams.sSearch))
            {
                string searchString = "";
                bool first = true;
                for (int i = 0; i < DTParams.iColumns; i++)
                {
                    if (DTParams.bSearchable[i])
                    {
                        string columnName = columns[i].Item1;

                        if (!first)
                            searchString += " or ";
                        else
                            first = false;

                        if (columns[i].Item2 == typeof(int))
                        {
                            searchString += columnName + ".ToString().StartsWith(\"" + DTParams.sSearch + "\")";
                        }
                        else
                        {
                            searchString += columnName + ".Contains(\"" + DTParams.sSearch + "\")";
                        }
                    }
                }
                data = data.Where(searchString);
            }
            string sortString = "";
            for (int i = 0; i < DTParams.iSortingCols; i++)
            {
                
                int columnNumber = DTParams.iSortCol[i];
                string columnName = columns[columnNumber].Item1;
                string sortDir = DTParams.sSortDir[i];
                if (i != 0)
                    sortString += ", ";
                sortString += columnName + " " + sortDir;
            }

            totalRecordsDisplay = data.Count();

            data = data.OrderBy(sortString);
            data = data.Skip(DTParams.iDisplayStart).Take(DTParams.iDisplayLength);

            return data;
        }
        private object BindV10Model(IValueProvider valueProvider)
        {
            DataTablesParam obj = new DataTablesParam();

            obj.iDisplayStart  = GetValue <int>(valueProvider, "start");
            obj.iDisplayLength = GetValue <int>(valueProvider, "length");
            obj.sSearch        = GetValue <string>(valueProvider, "search[value]");
            obj.bEscapeRegex   = GetValue <bool>(valueProvider, "search[regex]");
            obj.sEcho          = GetValue <int>(valueProvider, "draw");

            int colIdx = 0;

            while (true)
            {
                string colPrefix = String.Format("columns[{0}]", colIdx);
                string colName   = GetValue <string>(valueProvider, colPrefix + "[data]");
                if (String.IsNullOrWhiteSpace(colName))
                {
                    break;
                }
                obj.sColumnNames.Add(colName);
                obj.bSortable.Add(GetValue <bool>(valueProvider, colPrefix + "[orderable]"));
                obj.bSearchable.Add(GetValue <bool>(valueProvider, colPrefix + "[searchable]"));
                obj.sSearchValues.Add(GetValue <string>(valueProvider, colPrefix + "[search][value]"));
                obj.bEscapeRegexColumns.Add(GetValue <bool>(valueProvider, colPrefix + "[searchable][regex]"));
                colIdx++;
            }
            obj.iColumns = colIdx;
            colIdx       = 0;
            while (true)
            {
                string colPrefix   = String.Format("order[{0}]", colIdx);
                int?   orderColumn = GetValue <int?>(valueProvider, colPrefix + "[column]");
                if (orderColumn.HasValue)
                {
                    obj.iSortCol.Add(orderColumn.Value);
                    obj.sSortDir.Add(GetValue <string>(valueProvider, colPrefix + "[dir]"));
                    colIdx++;
                }
                else
                {
                    break;
                }
            }
            obj.iSortingCols = colIdx;
            return(obj);
        }
        public DataTablesResult<PartnerGridModel> GetPartnersGridModel(DataTablesParam dataTableParam)
        {
            Contract.Assert(dataTableParam != null);
            Contract.Assert(dataTableParam.iDisplayLength != 0);

            var list = this.Manager.FindAll(new PartnerAll(true));

            var query = (from entity in list
                         select new PartnerGridModel
                         {
                             Id = entity.Id,
                             Name = entity.Name,
                             Disabled = entity.Disabled
                         }).AsQueryable();

            return DataTablesResult.Create(query, dataTableParam);
        }
        public void ItMakesAppropriateQueries()
        {
            //arrange
            var source = DataContext.Models;
            var dataTablesParam = new DataTablesParam();
            dataTablesParam.iColumns = 2;
            dataTablesParam.bSearchable.Add(false);
            dataTablesParam.bSearchable.Add(true);

            dataTablesParam.sSearch = "Name 10";

            //act
            var result = new DataTablesResult<SomeModel, SomeModel>(source, dataTablesParam, model => model);
            var data = (DataTablesData) result.Data;
        
            //assert
            //TODO: need to check that appropriate SQL queries are made somehow.

        }
        public void Setup()
        {
            queryable = new List<SomeModel>()
            {
                new SomeModel()
                {
                    Category = 1,
                    DisplayName = "Cheddar",
                    Id = 123,
                    Scale = 123.456d,
                    Discounted = true
                }
            }.AsQueryable();

            dataTablesParam = new DataTablesParam();
            columns = TypeExtensions.GetSortedProperties<SomeModel>().Select((p, i) =>
                Tuple.Create(i, new ColInfo(p.Name, p.PropertyType))).ToArray();
            dataTablesParam.sSearchColumns = new List<string>(columns.Select(c => null as string));
            dataTablesParam.bSearchable = new List<bool>(columns.Select(c => true));

        }
        public void Setup()
        {
            queryable = new List<SomeModel>()
            {
                new SomeModel()
                {
                    Category = 1,
                    DisplayName = "Cheddar",
                    Id = 123,
                    Scale = 123.456d,
                    Discounted = true,
                    Cost = 123
                }
            }.AsQueryable();

            dataTablesParam = new DataTablesParam();
            columns = DataTablesTypeInfo<SomeModel>.Properties.Select((p, i) =>
                Tuple.Create(i, new DataTablesPropertyInfo(p.PropertyInfo, new DataTablesAttributeBase[]{}))).ToArray();
            dataTablesParam.sSearchValues = new List<string>(columns.Select(c => null as string));
            dataTablesParam.bSearchable = new List<bool>(columns.Select(c => true));

        }
        private DataTablesParam BindLegacyModel(IValueProvider valueProvider, int columns)
        {
            DataTablesParam obj = new DataTablesParam(columns);

            obj.iDisplayStart  = GetValue <int>(valueProvider, "iDisplayStart");
            obj.iDisplayLength = GetValue <int>(valueProvider, "iDisplayLength");
            obj.sSearch        = GetValue <string>(valueProvider, "sSearch");
            obj.bEscapeRegex   = GetValue <bool>(valueProvider, "bEscapeRegex");
            obj.iSortingCols   = GetValue <int>(valueProvider, "iSortingCols");
            obj.sEcho          = GetValue <int>(valueProvider, "sEcho");

            for (int i = 0; i < obj.iColumns; i++)
            {
                obj.bSortable.Add(GetValue <bool>(valueProvider, "bSortable_" + i));
                obj.bSearchable.Add(GetValue <bool>(valueProvider, "bSearchable_" + i));
                obj.sSearchValues.Add(GetValue <string>(valueProvider, "sSearch_" + i));
                obj.bEscapeRegexColumns.Add(GetValue <bool>(valueProvider, "bEscapeRegex_" + i));
                obj.iSortCol.Add(GetValue <int>(valueProvider, "iSortCol_" + i));
                obj.sSortDir.Add(GetValue <string>(valueProvider, "sSortDir_" + i));
            }
            return(obj);
        }
Exemple #18
0
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            DataTablesParam obj     = new DataTablesParam();
            var             request = controllerContext.HttpContext.Request.Params;

            obj.iDisplayStart  = Convert.ToInt32(request["iDisplayStart"]);
            obj.iDisplayLength = Convert.ToInt32(request["iDisplayLength"]);
            obj.iColumns       = Convert.ToInt32(request["iColumns"]);
            obj.sSearch        = request["sSearch"];
            obj.bEscapeRegex   = Convert.ToBoolean(request["bEscapeRegex"]);
            obj.iSortingCols   = Convert.ToInt32(request["iSortingCols"]);
            obj.sEcho          = int.Parse(request["sEcho"]);

            for (int i = 0; i < obj.iColumns; i++)
            {
                obj.bSortable.Add(Convert.ToBoolean(request["bSortable_" + i]));
                obj.bSearchable.Add(Convert.ToBoolean(request["bSearchable_" + i]));
                obj.sSearchColumns.Add(request["sSearch_" + i]);
                obj.bEscapeRegexColumns.Add(Convert.ToBoolean(request["bEscapeRegex_" + i]));
                obj.iSortCol.Add(Convert.ToInt32(request["iSortCol_" + i]));
                obj.sSortDir.Add(request["sSortDir_" + i]);
            }
            return(obj);
        }
Exemple #19
0
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            var valueProvider = bindingContext.ValueProvider;

            DataTablesParam obj = new DataTablesParam(GetValue <int>(valueProvider, "iColumns"));

            obj.iDisplayStart  = GetValue <int>(valueProvider, "iDisplayStart");
            obj.iDisplayLength = GetValue <int>(valueProvider, "iDisplayLength");
            obj.sSearch        = GetValue <string>(valueProvider, "sSearch");
            obj.bEscapeRegex   = GetValue <bool>(valueProvider, "bEscapeRegex");
            obj.iSortingCols   = GetValue <int>(valueProvider, "iSortingCols");
            obj.sEcho          = GetValue <int>(valueProvider, "sEcho");

            for (int i = 0; i < obj.iColumns; i++)
            {
                obj.bSortable.Add(GetValue <bool>(valueProvider, "bSortable_" + i));
                obj.bSearchable.Add(GetValue <bool>(valueProvider, "bSearchable_" + i));
                obj.sSearchColumns.Add(GetValue <string>(valueProvider, "sSearch_" + i));
                obj.bEscapeRegexColumns.Add(GetValue <bool>(valueProvider, "bEscapeRegex_" + i));
                obj.iSortCol.Add(GetValue <int>(valueProvider, "iSortCol_" + i));
                obj.sSortDir.Add(GetValue <string>(valueProvider, "sSortDir_" + i));
            }
            return(obj);
        }
        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);

        }
Exemple #21
0
 public static DataTablesResult <TSource> Create <TSource>(IQueryable <TSource> q, DataTablesParam dataTableParam,
                                                           ArrayOutputType?arrayOutput = null)
 {
     return(Create(q, dataTableParam, new ResponseOptions <TSource>()
     {
         ArrayOutputType = arrayOutput
     }));
 }
 public DataTablesResult<StudentViewModel> GetCollectionStudents(DataTablesParam dataTableParam)
 {
     var searchString = dataTableParam.GetSearchString();
     ViewBag.EditActionLink = "/Administration/EditStudent";
     ViewBag.DeleteActionLink = "/Administration/DeleteStudent";
     ViewBag.StatActionLink = "/Administration/Attendance";
     var students = StudentManagementService.GetStudentsPageable(pageInfo: dataTableParam.ToPageInfo(), searchString: searchString);
     return DataTableExtensions.GetResults(students.Items.Select(s => StudentViewModel.FromStudent(s, PartialViewToString("_EditGlyphLinks", s.Id))), dataTableParam, students.TotalCount);
 }
Exemple #23
0
        public DataTablesResult<SubjectListViewModel> GetSubjects(DataTablesParam dataTableParam)
        {
            var searchString = dataTableParam.GetSearchString();
            var subjects = ApplicationService<ISubjectManagementService>().GetSubjectsLecturer(WebSecurity.CurrentUserId, pageInfo: dataTableParam.ToPageInfo(), searchString: searchString);

            return DataTableExtensions.GetResults(subjects.Items.Select(_GetSubjectRow), dataTableParam, subjects.TotalCount);
        }
Exemple #24
0
 public static DataTablesResult <T> CreateResultUsingEnumerable <T>(IEnumerable <T> q, DataTablesParam dataTableParam,
                                                                    ArrayOutputType?arrayOutput = null)
 {
     return(Create(q.AsQueryable(), dataTableParam, arrayOutput));
 }
Exemple #25
0
        public static DataTablesResult <TSource> Create <TSource>(IQueryable <TSource> q, DataTablesParam dataTableParam,
                                                                  ResponseOptions <TSource> responseOptions = null)
        {
            var result = new DataTablesResult <TSource>(q, dataTableParam);

            var dictionaryTransform = DataTablesTypeInfo <TSource> .ToDictionary(responseOptions);

            result.Data = result.Data
                          .Transform <TSource, Dictionary <string, object> >(dictionaryTransform)
                          .Transform <Dictionary <string, object>, Dictionary <string, object> >(StringTransformers.StringifyValues);

            result.Data = ApplyOutputRules(result.Data, responseOptions);

            return(result);
        }
Exemple #26
0
        public static DataTablesResult <TSource> Create <TSource>(IQueryable <TSource> q, DataTablesParam dataTableParam)
        {
            var result = new DataTablesResult <TSource>(q, dataTableParam);

            result.Data = result.Data
                          .Transform <TSource, Dictionary <string, object> >(DataTablesTypeInfo <TSource> .ToDictionary)
                          .Transform <Dictionary <string, object>, Dictionary <string, object> >(StringTransformers.StringifyValues)
                          .Transform <Dictionary <string, object>, object[]>(d => d.Values.ToArray());;
            return(result);
        }
Exemple #27
0
 public static DataTablesResult <T> CreateResultUsingEnumerable <T>(IEnumerable <T> q, DataTablesParam dataTableParam)
 {
     return(Create(q.AsQueryable(), dataTableParam));
 }
 public static DataTablesResult <TSource> Create <TSource>(IQueryable <TSource> q, DataTablesParam dataTableParam)
 {
     return(Create(q, dataTableParam, new ResponseOptions <TSource>()));
 }
Exemple #29
0
        public DataTablesResult<ProjectUserListViewModel> GetProjectUsers(DataTablesParam dataTablesParam)
        {
            var searchString = dataTablesParam.GetSearchString();
            var projectUsers = ProjectManagementService.GetProjectUsers(pageInfo: dataTablesParam.ToPageInfo(),
                searchString: searchString);
            var projectId = int.Parse(Request.QueryString["projectId"]);
            if (User.IsInRole("lector") && ProjectManagementService.GetProject(projectId).CreatorId == WebSecurity.CurrentUserId)
            {
                return DataTableExtensions.GetResults(projectUsers.Items.Select(model => FromProjectUser(model, PartialViewToString("_ProjectUsersGridActions", FromProjectUser(model)))).Where(e => e.ProjectId == projectId && e.UserName != GetProjectCreatorName(projectId)), dataTablesParam, projectUsers.TotalCount);
            }

            return DataTableExtensions.GetResults(projectUsers.Items.Select(FromProjectUser).Where(e => e.ProjectId == projectId && e.UserName != GetProjectCreatorName(projectId)), dataTablesParam, projectUsers.TotalCount);
        }
Exemple #30
0
        public DataTablesResult<ProjectListViewModel> GetProjects(DataTablesParam dataTableParam)
        {
            var searchString = dataTableParam.GetSearchString();
            var projects = ProjectManagementService.GetProjects(pageInfo: dataTableParam.ToPageInfo(), searchString: searchString);

            if (User.IsInRole("lector"))
            {
                return DataTableExtensions.GetResults(projects.Items.Select(model => FromProject(model, PartialViewToString("_ProjectsGridActions", FromProject(model)))).Where(e => e.IsAssigned), dataTableParam, projects.TotalCount);
            }

            return DataTableExtensions.GetResults(projects.Items.Select(FromProject).Where(e => e.IsAssigned), dataTableParam, projects.TotalCount);
        }
Exemple #31
0
        public DataTablesResult<BugListViewModel> GetAllBugs(DataTablesParam dataTableParam)
        {
            var searchString = dataTableParam.GetSearchString();
            var bugs = BugManagementService.GetAllBugs(pageInfo: dataTableParam.ToPageInfo(), searchString: searchString);

            if (User.IsInRole("lector"))
            {
                if (_currentProjectId != 0)
                {
                    return DataTableExtensions.GetResults(bugs.Items.Select(model => FromBug(model, PartialViewToString("_BugsGridActions", FromBug(model)))).Where(e => e.ProjectId == _currentProjectId), dataTableParam, bugs.TotalCount);
                }

                return DataTableExtensions.GetResults(bugs.Items.Select(model => FromBug(model, PartialViewToString("_BugsGridActions", FromBug(model)))).Where(e => e.IsAssigned), dataTableParam, bugs.TotalCount);
            }

            if (_currentProjectId != 0)
            {
                return DataTableExtensions.GetResults(bugs.Items.Select(FromBug).Where(e => e.ProjectId == _currentProjectId), dataTableParam, bugs.TotalCount);
            }

            return DataTableExtensions.GetResults(bugs.Items.Select(FromBug).Where(e => e.IsAssigned), dataTableParam, bugs.TotalCount);
        }
        public DataTablesResult<TimeSlotViewModel> GetAllRecords(DataTablesParam dataTableParam)
        {
              if (Session["CurrentSchedule"] == null)
            {
                RedirectToAction("Index", "Schedule");

            }
         
             var schedule = (Schedule)Session["CurrentSchedule"];

            var svc = new TimeSlotAppService();
          List<TimeSlot> ats = svc.GetAllTimeSlotByScheduleId(schedule.ScheduleId);
            var atVm = new List<TimeSlotViewModel>();
            var ci = new CultureInfo("es-CO");

            foreach (var itm in ats)
            {

                var itmVm = new TimeSlotViewModel
                {
                    ScheduleId=itm.ScheduleId,
                    MonthName= schedule.Month,
                    TimeSlotId= itm.TimeSlotId,
                    OfficeId= itm.OfficeId,
                    Day= itm.Day,
                    StartTime = itm.StartTime,
                    EndTime = itm.EndTime,
                    StartTimeText = itm.StartTime.ToShortTimeString(),
                    EndTimeText = itm.EndTime.ToShortTimeString(),
                    OfficeAddress = string.Format("{0}({1})", itm.Office.Address, itm.Office.GeoCity.Name),
                    DayName= new DateTime(schedule.Year, schedule.Month, itm.Day).DayOfWeek.ToString(ci) + " " + itm.Day 
                    
                };

              




                var sb = new StringBuilder();

                string editUrl = Url.Action("Edit", "TimeSlot");
                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.TimeSlotId+ "\"><i class=\"fa fa-edit\"></i>&nbsp;Editar Disponibilidad</a></li>");
                sb.AppendLine("</ul>");
                sb.AppendLine("</div>");






                var actionButton = sb.ToString();

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

            }

            var atmVmQueryable = atVm.AsQueryable();


            return DataTablesResult.Create(atmVmQueryable, dataTableParam);

        }
        static DataTablesParam GetEmptyParam(int columns)
        {
            var returnVar = new DataTablesParam(columns);
            returnVar.iDisplayLength = DefaultTestCasesLength;
            returnVar.iSortingCols = 1;
            returnVar.sEcho = 1;
            returnVar.sSearch = "";
            returnVar.bEscapeRegexColumns.AddRange(Enumerable.Repeat(false, columns));
            returnVar.bSearchable.AddRange(Enumerable.Repeat(true, columns));
            returnVar.bSortable.AddRange(Enumerable.Repeat(true, columns));
            returnVar.iSortCol.AddRange(Enumerable.Repeat(0, columns));
            returnVar.sSearchValues.AddRange(Enumerable.Repeat("", columns));
            returnVar.sSortDir.AddRange(Enumerable.Repeat<string>(null, columns));

            return returnVar;
        }
        public DataTablesResult<UserGridModel> GetUsersGridModel2(DataTablesParam dataTableParam)
        {
            Contract.Assert(dataTableParam != null);
            Contract.Assert(dataTableParam.iDisplayLength != 0);

            var list = this.Manager.FindAll(new UserAll());

            var query = (from u in list
                         select new UserGridModel
                                 {
                                     Id = u.Id,
                                     Name = u.Name,
                                     Email = u.Email,
                                     Login = u.UserPasswordCredential != null ? u.UserPasswordCredential.Login : string.Empty,
                                 }).AsQueryable();

            return DataTablesResult.Create(query, dataTableParam);
        }
Exemple #35
0
        /// <typeparam name="TSource"></typeparam>
        /// <typeparam name="TTransform"></typeparam>
        /// <param name="q">A queryable for the data. The properties of this can be marked up with [DataTablesAttribute] to control sorting/searchability/visibility</param>
        /// <param name="dataTableParam"></param>
        /// <param name="transform">//a transform for custom column rendering e.g. to do a custom date row => new { CreatedDate = row.CreatedDate.ToString("dd MM yy") } </param>
        /// <returns></returns>
        public static DataTablesResult <TSource> Create <TSource, TTransform>(IQueryable <TSource> q, DataTablesParam dataTableParam, Func <TSource, TTransform> transform)
        {
            var result = new DataTablesResult <TSource>(q, dataTableParam);

            result.Data = result.Data
                          .Transform <TSource, Dictionary <string, object> >(row => TransformTypeInfo.MergeTransformValuesIntoDictionary(transform, row))
                          .Transform <Dictionary <string, object>, Dictionary <string, object> >(StringTransformers.StringifyValues)
                          .Transform <Dictionary <string, object>, object[]>(d => d.Values.ToArray());

            return(result);
        }
        public DataTablesResult<CountryViewModel> GetAllRecords(DataTablesParam dataTableParam)
        {

            var svc = new GeoCountryAppService();
            var lst = svc.GetAllGeoCountry();
            var lstVm = new List<CountryViewModel>();
            foreach (var itm in lst)
            {

                var itmVm = new CountryViewModel
                {

                    Name = itm.Name,
                    GeoCountryId = itm.GeoCountryId,

                };

                if (itm.Latitude != null)
                {
                    itmVm.Latitude = itm.Latitude;
                    itmVm.LatitudeText = GeoAngle.FromDouble((double)itm.Latitude).ToString();
                }
                else
                {
                    itmVm.Latitude = 0;
                    itmVm.LatitudeText = "Sín Coordenadas";
                }



                if (itm.Longitude != null)
                {
                    itmVm.Longitude = 0;
                    itmVm.LongitudeText = GeoAngle.FromDouble((double)itm.Longitude).ToString();
                }
                else
                {
                    itmVm.Longitude = 0;
                    itmVm.LongitudeText = "Sín Coordenadas";
                }




                var sb = new StringBuilder();

                string editUrl = Url.Action("Edit", "Country");
                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.GeoCountryId + "\"><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);

        }
 public virtual int[] ExecuteParams(DataTablesParam dataTablesParam)
 {
     var result = new DataTablesResult<SomeModel>(SomeModelQueryable, dataTablesParam);
     var data = result.Data;
     return data.aaData.Select(row => ((SomeModel)row).Id).ToArray();
 }
Exemple #38
0
        /// <typeparam name="TSource"></typeparam>
        /// <typeparam name="TTransform"></typeparam>
        /// <param name="q">A queryable for the data. The properties of this can be marked up with [DataTablesAttribute] to control sorting/searchability/visibility</param>
        /// <param name="dataTableParam"></param>
        /// <param name="transform">//a transform for custom column rendering e.g. to do a custom date row => new { CreatedDate = row.CreatedDate.ToString("dd MM yy") } </param>
        /// <returns></returns>
        public static DataTablesResult <TSource> Create <TSource, TTransform>(IQueryable <TSource> q, DataTablesParam dataTableParam,
                                                                              Func <TSource, TTransform> transform, ResponseOptions <TSource> responseOptions = null)
        {
            var result = new DataTablesResult <TSource>(q, dataTableParam);

            result.Data = result.Data
                          .Transform <TSource, Dictionary <string, object> >(row => TransformTypeInfo.MergeTransformValuesIntoDictionary(transform, row))
                          .Transform <Dictionary <string, object>, Dictionary <string, object> >(StringTransformers.StringifyValues);

            result.Data = ApplyOutputRules(result.Data, responseOptions);

            return(result);
        }
Exemple #39
0
 public static DataTablesResult <TRes> Create <T, TRes>(IQueryable <T> q, DataTablesParam dataTableParam, Func <T, TRes> transform)
 {
     return(new DataTablesResult <T, TRes>(q, dataTableParam, transform));
 }
        public DataTablesResult<SubscriptionViewModel> GetAllRecords(DataTablesParam dataTableParam)
        {
              if (Session["CurrentPatient"] == null)
            {
                RedirectToAction("Index", "Patient");

            }
         
             var patient = (Patient)Session["CurrentPatient"];

            var svc = new SubscriptionAppService();
          List<Subscription> ats = svc.GetAllSubscriptionByPatientId(patient.PatientId);
            var atVm = new List<SubscriptionViewModel>();


            foreach (var itm in ats)
            {

                var itmVm = new SubscriptionViewModel
                {

               
                    SubscriptionId= itm.SubscriptionId,
                    SubscriptionTypeName=itm.SubscriptionType.Name,
                    IsActive=itm.IsActive,
                    IsActiveText=itm.IsActive==1 ? "Activa":"Inactiva"

                };

              




                var sb = new StringBuilder();

                string editUrl = Url.Action("Edit", "Subscription");
                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.SubscriptionId+ "\"><i class=\"fa fa-edit\"></i>&nbsp;Editar Subscripción</a></li>");
                sb.AppendLine("</ul>");
                sb.AppendLine("</div>");






                var actionButton = sb.ToString();

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

            }

            var atmVmQueryable = atVm.AsQueryable();


            return DataTablesResult.Create(atmVmQueryable, dataTableParam);

        }
        public DataTablesResult<DiseaseCategoryViewModel> GetAllRecords(DataTablesParam dataTableParam)
        {

            var svc = new DiseaseCategoryAppService();
            var lst = svc.GetAllDiseaseCategory();
            var lstVm = new List<DiseaseCategoryViewModel>();
            foreach (var itm in lst)
            {

                var itmVm = new DiseaseCategoryViewModel
                {

                    Name = itm.Name,
                    DiseaseCategoryId= itm.DiseaseCategoryId,

                };

              




                var sb = new StringBuilder();

                string editUrl = Url.Action("Edit", "DiseaseCategory");
                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.DiseaseCategoryId+ "\"><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);

        }
Exemple #42
0
        public static DataTablesResult <TSource> Create <TSource>(IQueryable <TSource> q, DataTablesParam dataTableParam,
                                                                  ArrayOutputType?arrayOutput = null)
        {
            var result = new DataTablesResult <TSource>(q, dataTableParam);

            result.Data = result.Data
                          .Transform <TSource, Dictionary <string, object> >(DataTablesTypeInfo <TSource> .ToDictionary)
                          .Transform <Dictionary <string, object>, Dictionary <string, object> >(StringTransformers.StringifyValues);

            result.Data = ApplyOutputRules(result.Data, arrayOutput);

            return(result);
        }
        public DataTablesResult<OfficeViewModel> GetAllRecords(DataTablesParam dataTableParam)
        {
              if (Session["CurrentEmployee"] == null)
            {
                RedirectToAction("Index", "Employee");

            }
         
             var employee = (Employee)Session["CurrentEmployee"];

            var svc = new OfficeAppService();
            List<Office> ats = svc.GetOfficesByEmployeeId(employee.EmployeeId);
            var atVm = new List<OfficeViewModel>();


            foreach (var itm in ats)
            {

                var itmVm = new OfficeViewModel
                {

               
                    OfficeId= itm.OfficeId,
                    Address = itm.Address,
                    EmployeeId = employee.EmployeeId,
                    Number = itm.Number,
                    GeoStateName=itm.GeoCity.GeoState.Name,
                    GeoCityName = itm.GeoCity.Name,
                    
                    
                    

                };

              
                var sb = new StringBuilder();

                string editUrl = Url.Action("Edit", "Office");
                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.OfficeId+ "\"><i class=\"fa fa-edit\"></i>&nbsp;Editar Oficina</a></li>");
                sb.AppendLine("</ul>");
                sb.AppendLine("</div>");






                var actionButton = sb.ToString();

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

            }

            var atmVmQueryable = atVm.AsQueryable();


            return DataTablesResult.Create(atmVmQueryable, dataTableParam);

        }
Exemple #44
0
 public static DataTablesResult <T> Create <T>(IQueryable <T> q, DataTablesParam dataTableParam)
 {
     return(new DataTablesResult <T, T>(q, dataTableParam, t => t));
 }
        public DataTablesResult<RecordViewModel> GetOperations(DataTablesParam dataTableParam)
        {

            var svc = new RecordAppService();
            var redords = svc.GetRecords(Convert.ToDateTime(Session["StartDate"].ToString()), Convert.ToDateTime(Session["EndDate"].ToString()).AddDays(1), Session["Operation"].ToString());
            var usersVm = new List<RecordViewModel>();

            foreach (var itm in redords)
            {

                var itmVm = new RecordViewModel
                {
                    RecordId = itm.RecordId,
                    OperationName = itm.OperationName,
                    UserId = itm.UserId,
                    SessionId = itm.SessionId,
                    UserName = itm.User.UserName,
                    StartDate = itm.StartDate,
                    EndDate = itm.EndDate,
                    Message = itm.Message,
                    MessageCode = itm.MessageCode

                };

                var sb = new StringBuilder();

                string editUrl = Url.Action("Edit", "Record");
                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 + "?pRecordId=" + itmVm.RecordId + "\"><i class=\"fa fa-edit\"></i>&nbsp;Ver detalle " + itmVm.OperationName + "</a></li>");
                sb.AppendLine("</ul>");
                sb.AppendLine("</div>");

                var actionButton = sb.ToString();

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

            }

            var atVmQueryable = usersVm.AsQueryable();


            return DataTablesResult.Create(atVmQueryable, dataTableParam);
        }
 public DataTablesResult<GroupViewModel> GetCollectionGroups(DataTablesParam dataTableParam)
 {
     var searchString = dataTableParam.GetSearchString();
     ViewBag.EditActionLink = "/Administration/EditGroup";
     ViewBag.DeleteActionLink = "/Administration/DeleteGroup";
     var groups = GroupManagementService.GetGroupsPageable(pageInfo: dataTableParam.ToPageInfo(), searchString: searchString);
     return DataTableExtensions.GetResults(groups.Items.Select(g => GroupViewModel.FormGroup(g, PartialViewToString("_EditGlyphLinks", g.Id))), dataTableParam, groups.TotalCount);
 }
        public IQueryable <T> ApplyFiltersAndSort <T>(DataTablesParam dtParameters, IQueryable <T> data, DataTablesPropertyInfo[] columns)
        {
            if (!String.IsNullOrEmpty(dtParameters.sSearch))
            {
                var parts      = new List <string>();
                var parameters = new List <object>();
                for (var i = 0; i < dtParameters.iColumns; i++)
                {
                    if (dtParameters.bSearchable[i])
                    {
                        try
                        {
                            parts.Add(GetFilterClause(dtParameters.sSearch, columns[i], parameters));
                        }
                        catch (Exception)
                        {
                            //if the clause doesn't work, skip it!
                        }
                    }
                }
                var values = parts.Where(p => p != null);
                data = data.Where(string.Join(" or ", values), parameters.ToArray());
            }
            for (int i = 0; i < dtParameters.sSearchValues.Count; i++)
            {
                if (dtParameters.bSearchable[i])
                {
                    var searchColumn = dtParameters.sSearchValues[i];
                    if (!string.IsNullOrWhiteSpace(searchColumn))
                    {
                        DataTablesPropertyInfo column = FindColumn(dtParameters, columns, i);
                        var parameters   = new List <object>();
                        var filterClause = GetFilterClause(searchColumn, column, parameters);
                        if (string.IsNullOrWhiteSpace(filterClause) == false)
                        {
                            data = data.Where(filterClause, parameters.ToArray());
                        }
                    }
                }
            }
            string sortString = "";

            for (int i = 0; i < dtParameters.iSortingCols; i++)
            {
                int columnNumber = dtParameters.iSortCol[i];
                DataTablesPropertyInfo column = FindColumn(dtParameters, columns, columnNumber);
                string columnName             = column.PropertyInfo.Name;
                string sortDir = dtParameters.sSortDir[i];
                if (i != 0)
                {
                    sortString += ", ";
                }
                sortString += columnName + " " + sortDir;
            }
            if (string.IsNullOrWhiteSpace(sortString))
            {
                sortString = columns[0].PropertyInfo.Name;
            }
            data = data.OrderBy(sortString);


            return(data);
        }
 public DataTablesResult<LecturerViewModel> GetCollectionLecturers(DataTablesParam dataTableParam)
 {
     var searchString = dataTableParam.GetSearchString();
     ViewBag.EditActionLink = "/Administration/EditProfessor";
     ViewBag.DeleteActionLink = "/Administration/DeleteLecturer";
     ViewBag.StatActionLink = "/Administration/Attendance";
     var lecturers = LecturerManagementService.GetLecturersPageable(pageInfo: dataTableParam.ToPageInfo(), searchString: searchString);
     return DataTableExtensions.GetResults(lecturers.Items.Select(l => LecturerViewModel.FormLecturers(l, PartialViewToString("_EditGlyphLinks", l.Id))), dataTableParam, lecturers.TotalCount);
 }
        public DataTablesResult<TimeSlotViewModel> GetAllRecords(DataTablesParam dataTableParam)
        {
            if (Session["AvailableSchedule"] == null)
            {
                return DataTablesResult.Create(new List<TimeSlotViewModel>().AsQueryable(), dataTableParam);

            }

            var atVm = (List<TimeSlotViewModel>)Session["AvailableSchedule"];


            foreach (var itm in atVm)
            {

               


                var sb = new StringBuilder();

                string editUrl ="#";
                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 class=\"assign-link\" href=\"" + editUrl + "?id=-1\"><i class=\"fa fa-plus\"></i>&nbsp;Asignar</a></li>");
                sb.AppendLine("</ul>");
                sb.AppendLine("</div>");






                var actionButton = sb.ToString();

                itm.ActionButton = actionButton;
         

            }

            var atmVmQueryable = atVm.AsQueryable();


            return DataTablesResult.Create(atmVmQueryable, dataTableParam);

        }
        public DataTablesResult<ScheduleViewModel> GetAllRecords(DataTablesParam dataTableParam)
        {
              if (Session["CurrentEmployee"] == null)
            {
                RedirectToAction("Index", "Employee");

            }
         
             var employee = (Employee)Session["CurrentEmployee"];

            var svc = new ScheduleAppService();
          List<Schedule> ats = svc.GetAllScheduleByEmployeeId(employee.EmployeeId);
            var atVm = new List<ScheduleViewModel>();

            var ci = new CultureInfo("es-CO");
            foreach (var itm in ats)
            {

                var itmVm = new ScheduleViewModel
                {

               
                    ScheduleId= itm.ScheduleId,
                    EmployeeId = itm.EmployeeId,
                    Month=itm.Month,
                    Year = itm.Year,
                    MonthName = new DateTime(2010, itm.Month, 1).ToString("MMMM", ci)
                };

              




                var sb = new StringBuilder();

                string editUrl = Url.Action("Edit", "Schedule");
                string timeslotUrl = Url.Action("Index", "TimeSlot");
                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.ScheduleId+ "\"><i class=\"fa fa-edit\"></i>&nbsp;Editar Agenda</a></li>");
                sb.AppendLine("<li><a href=\"" + timeslotUrl + "?id=" + itmVm.ScheduleId + "\"><i class=\"fa fa-edit\"></i>&nbsp;Asignar Disponibilidad</a></li>");
                sb.AppendLine("</ul>");
                sb.AppendLine("</div>");






                var actionButton = sb.ToString();

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

            }

            var atmVmQueryable = atVm.AsQueryable();


            return DataTablesResult.Create(atmVmQueryable, dataTableParam);

        }