Example #1
0
        public ActionResult ValueList(int extendedAttributeId, DataTablesParam dataTableParam)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
            {
                return(AccessDeniedView());
            }

            var values = _extendedAttributeService.GetExtendedAttributeValues(extendedAttributeId);

            var total  = values.Count();
            var result = new DataTablesData
            {
                iTotalRecords        = total,
                iTotalDisplayRecords = total,
                sEcho  = dataTableParam.sEcho,
                aaData = values.Select(x =>
                {
                    var model = x.ToModel();
                    //locales
                    //AddLocales(_languageService, model.Locales, (locale, languageId) =>
                    //{
                    //    locale.Name = x.GetLocalized(y => y.Name, languageId, false, false);
                    //});
                    return(model);
                }).Cast <object>().ToArray(),
            };

            return(new JsonResult
            {
                Data = result
            });
        }
Example #2
0
        public ActionResult List(DataTablesParam dataTableParam)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageUsers))
            {
                return(AccessDeniedView());
            }

            var users = _userService.GetOnlineUsers(DateTime.UtcNow.AddMinutes(-_userSettings.OnlineUserMinutes),
                                                    null, dataTableParam.PageIndex, dataTableParam.PageSize);

            var total  = users.Count();
            var result = new DataTablesData
            {
                iTotalRecords        = total,
                iTotalDisplayRecords = total,
                sEcho  = dataTableParam.sEcho,
                aaData = users.Select(x =>
                {
                    return(new OnlineUserModel()
                    {
                        Id = x.Id,
                        UserInfo = x.IsRegistered() ? x.Email : _localizationService.GetResource("Admin.Users.Guest"),
                        LastIpAddress = x.LastIpAddress,
                        Location = _geoCountryLookup.LookupCountryName(x.LastIpAddress),
                        LastActivityDate = _dateTimeHelper.ConvertToUserTime(x.LastActivityDateUtc, DateTimeKind.Utc),
                        LastVisitedPage = x.GetAttribute <string>(SystemUserAttributeNames.LastVisitedPage)
                    });
                }).Cast <object>().ToArray(),
            };

            return(new JsonResult
            {
                Data = result
            });
        }
Example #3
0
        public JsonResult GetDatosFamiliaresTable(DataTablesParam param)
        {
            int IdentityPersonal = SessionPersister.AccountSession.IdPersonal;
            List <FamiliarDomainModel> familiares = new List <FamiliarDomainModel>();

            int pageNo = 1;

            if (param.iDisplayStart >= param.iDisplayLength)
            {
                pageNo = (param.iDisplayStart / param.iDisplayLength) + 1;
            }

            int totalCount = 0;

            if (param.sSearch != null)
            {
                familiares = ifamiliarBusiness.GetFamiliaresById(IdentityPersonal).Where(p => p.StrNombre.Contains(param.sSearch)).ToList();
                ///ifamiliarBusiness.GetFamiliaresHijosById(IdentityPersonal).Where(p => p.StrNombre.Contains(param.sSearch)).ToList();
            }
            else
            {
                totalCount = ifamiliarBusiness.GetFamiliaresHijosById(IdentityPersonal).Count();
                familiares = ifamiliarBusiness.GetFamiliaresById(IdentityPersonal).OrderBy(p => p.IdPersonal)
                             .Skip((pageNo - 1) * param.iDisplayLength).Take(param.iDisplayLength).ToList();
                //ifamiliarBusiness.GetFamiliaresHijosById(IdentityPersonal).OrderBy(p => p.IdPersonal)
                //.Skip((pageNo - 1) * param.iDisplayLength).Take(param.iDisplayLength).ToList();
            }
            return(Json(new
            {
                aaData = familiares,
                sEcho = param.sEcho,
                iTotalDisplayRecords = familiares.Count(),
                iTotalRecords = familiares.Count()
            }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult GetDatosCompetenciaTiTable(DataTablesParam param)
        {
            int IdentityPersonal = SessionPersister.AccountSession.IdPersonal;
            List <CompetenciasTiDomainModel> competencias = new List <CompetenciasTiDomainModel>();

            int pageNo = 1;

            if (param.iDisplayStart >= param.iDisplayLength)
            {
                pageNo = (param.iDisplayStart / param.iDisplayLength) + 1;
            }

            int totalCount = 0;

            if (param.sSearch != null)
            {
                competencias = icompetenciasTiBusiness.GetCompetenciasTi(IdentityPersonal).Where(p => p.CompetenciaTiDomainModel.StrDescripcion.Contains(param.sSearch)).ToList();
            }
            else
            {
                totalCount   = icompetenciasTiBusiness.GetCompetenciasTi(IdentityPersonal).Count();
                competencias = icompetenciasTiBusiness.GetCompetenciasTi(IdentityPersonal).OrderBy(p => p.IdPersonal)
                               .Skip((pageNo - 1) * param.iDisplayLength).Take(param.iDisplayLength).ToList();
            }
            return(Json(new
            {
                aaData = competencias,
                sEcho = param.sEcho,
                iTotalDisplayRecords = competencias.Count(),
                iTotalRecords = competencias.Count()
            }, JsonRequestBehavior.AllowGet));
        }
Example #5
0
        public JsonResult GetCompetencias(DataTablesParam param)
        {
            int IdentityPersonal = SessionPersister.AccountSession.IdPersonal;
            List <CompetenciasPersonalDomainModel> competenciaDM = new List <CompetenciasPersonalDomainModel>();

            int pageNo = 1;

            if (param.iDisplayStart >= param.iDisplayLength)
            {
                pageNo = (param.iDisplayStart / param.iDisplayLength) + 1;
            }

            int totalCount = 0;

            if (param.sSearch != null)
            {
                competenciaDM = icompetenciaPersonalBusiness.GetAllCompetenciasPersonal(IdentityPersonal).Where(p => p.dteFechaRegistro.ToString().Contains(param.sSearch)).ToList();
            }
            else
            {
                totalCount = icompetenciaPersonalBusiness.GetAllCompetenciasPersonal(IdentityPersonal).Count();

                competenciaDM = icompetenciaPersonalBusiness.GetAllCompetenciasPersonal(IdentityPersonal).OrderBy(p => p.dteFechaRegistro)
                                .Skip((pageNo - 1) * param.iDisplayLength).Take(param.iDisplayLength).ToList();
            }
            return(Json(new
            {
                aaData = competenciaDM,
                sEcho = param.sEcho,
                iTotalDisplayRecords = competenciaDM.Count(),
                iTotalRecords = competenciaDM.Count()
            }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult LoadUserEnrolledList(DataTablesParam param, string CourseID)
        {
            List <VMViewCourseUser> CourseUserList = new List <VMViewCourseUser>();
            DAL SQLcon     = new DAL();
            int pageNo     = 1;
            int totalCount = 0;

            if (param.iDisplayStart >= param.iDisplayLength)
            {
                pageNo = (param.iDisplayStart / param.iDisplayLength) + 1;
            }

            totalCount     = SQLcon.ViewCourseUserByCourseID(CourseID).Count();
            CourseUserList = SQLcon.ViewCourseUserByCourseID(CourseID).Select(x => new VMViewCourseUser
            {
                EmployeeNumber = x.EmployeeNumber,
                EmpName        = x.EmpName,
                Department     = x.Department,
                CompletionDate = x.CompletionDate
            }).AsEnumerable().ToList();

            return(Json(new
            {
                aaData = CourseUserList,
                eEcho = param.sEcho,
                iTotalDisplayRecords = totalCount,
                iTotalRecords = CourseUserList.Count()
            }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult LoadCourseDetails(DataTablesParam param)
        {
            List <VMViewCourses> CoursesD = new List <VMViewCourses>();
            DAL SQLcon     = new DAL();
            int pageNo     = 1;
            int totalCount = 0;

            if (param.iDisplayStart >= param.iDisplayLength)
            {
                pageNo = (param.iDisplayStart / param.iDisplayLength) + 1;
            }



            totalCount = SQLcon.ViewCoursesList().Count();
            CoursesD   = SQLcon.ViewCoursesList().Select(x => new VMViewCourses
            {
                ID          = x.ID,
                Course      = x.Course,
                Description = x.Description
            }).AsEnumerable().ToList();


            return(Json(new
            {
                aaData = CoursesD,
                eEcho = param.sEcho,
                iTotalDisplayRecords = totalCount,
                iTotalRecords = CoursesD.Count()
            }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult getTimeReg(DataTablesParam param, DateTime dFrom, DateTime dTo, int customerId, int projectId)
        {
            //Init and calculate variables
            int    pageNo = 1;
            string crit   = "";

            if (param.sSearch != null)
            {
                crit = param.sSearch.ToUpper();
            }
            if (param.iDisplayStart >= param.iDisplayLength)
            {
                pageNo = (param.iDisplayStart / param.iDisplayLength) + 1;
            }

            pdsTidRedLiveEntities db              = new pdsTidRedLiveEntities();
            int               userId              = Convert.ToInt32(Session["userId"]);
            int               totalRecords        = 0;
            int               totalDisplayRecords = 0;
            CTimeTrack        ctt    = new CTimeTrack();
            List <CTimeTrack> listTT = ctt.getMyTimeTracks(param, userId, dFrom, dTo, customerId, projectId, ref totalRecords, ref totalDisplayRecords);

            return(Json(new
            {
                aaData = listTT,
                sEcho = param.sEcho,
                iTotalDisplayRecords = totalDisplayRecords,
                iTotalRecords = totalRecords
            }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult getProjects(DataTablesParam param, int customerID)
        {
            int    pageNo = 1;
            string crit   = "";

            if (param.sSearch != null)
            {
                crit = param.sSearch.ToUpper();
            }
            if (param.iDisplayStart >= param.iDisplayLength)
            {
                pageNo = (param.iDisplayStart / param.iDisplayLength) + 1;
            }

            pdsTidRedLiveEntities db = new pdsTidRedLiveEntities();
            int totalCount           = db.project.Where(x => x.customerID == customerID).Count();
            //int totalCount = db.project.Count();
            List <CProject> projList = db.project.Select(x => new CProject
            {
                projectID   = x.projectID,
                customerID  = x.customerID,
                projectName = x.projectName,
                active      = x.active
            }).Where(x => x.customerID == customerID).ToList();


            if (crit != null && crit != "")
            {
                projList = projList.Where(x => x.projectName.ToUpper().Contains(crit)).ToList();
            }

            if (param.iSortCol_0 == 0 && param.sSortDir_0 == "asc")
            {
                projList = projList.OrderBy(o => o.projectName).ToList();
            }
            if (param.iSortCol_0 == 0 && param.sSortDir_0 == "desc")
            {
                projList = projList.OrderByDescending(o => o.projectName).ToList();
            }
            if (param.iSortCol_0 == 1 && param.sSortDir_0 == "asc")
            {
                projList = projList.OrderBy(o => o.active).ToList();
            }
            if (param.iSortCol_0 == 1 && param.sSortDir_0 == "desc")
            {
                projList = projList.OrderByDescending(o => o.active).ToList();
            }

            int countToDisplay = projList.Count();

            projList = projList.Skip((pageNo - 1) * param.iDisplayLength).Take(param.iDisplayLength).ToList();

            return(Json(new
            {
                aaData = projList,
                sEcho = param.sEcho,
                iTotalDisplayRecords = countToDisplay,
                iTotalRecords = totalCount
            }, JsonRequestBehavior.AllowGet));
        }
Example #10
0
        public JsonResult LoadUserCurrentCourse(DataTablesParam param)
        {
            List <VMELearningCousesProgress> QuestList = new List <VMELearningCousesProgress>();
            var userID     = Session["EmployeeNumber"].ToString();
            DAL SQLcon     = new DAL();
            int pageNo     = 1;
            int totalCount = 0;

            if (param.iDisplayStart >= param.iDisplayLength)
            {
                pageNo = (param.iDisplayStart / param.iDisplayLength) + 1;
            }

            totalCount = SQLcon.ViewCurrentEmployeeCoursebyEmployeeNumber(userID).Count();
            QuestList  = SQLcon.ViewCurrentEmployeeCoursebyEmployeeNumber(userID).Select(x => new VMELearningCousesProgress
            {
                ID             = x.ID,
                EmployeeNumber = x.EmployeeNumber,
                CourseID       = x.CourseID,
                Course         = x.Course,
                Progress       = x.Progress,
                Score          = x.Score,
                EnrolledDate   = x.EnrolledDate,
                CompletionDate = x.CompletionDate,
                ConsumedTime   = x.ConsumedTime
            }).AsEnumerable().ToList();

            return(Json(new
            {
                aaData = QuestList,
                eEcho = param.sEcho,
                iTotalDisplayRecords = totalCount,
                iTotalRecords = QuestList.Count()
            }, JsonRequestBehavior.AllowGet));
        }
Example #11
0
        public ActionResult LoadEmployeeByCourseID(DataTablesParam param, string CourseID)
        {
            List <VMViewEmployeeCourseStatus> EmployeeD = new List <VMViewEmployeeCourseStatus>();
            DAL SQLcon     = new DAL();
            int pageNo     = 1;
            int totalCount = 0;

            if (param.iDisplayStart >= param.iDisplayLength)
            {
                pageNo = (param.iDisplayStart / param.iDisplayLength) + 1;
            }

            totalCount = SQLcon.ViewEmployeeCourseTakenByCourseID(CourseID).Count();
            EmployeeD  = SQLcon.ViewEmployeeCourseTakenByCourseID(CourseID).Select(x => new VMViewEmployeeCourseStatus
            {
                EmployeeNumber = x.EmployeeNumber,
                EmpName        = x.EmpName,
                CampiagnName   = x.CampiagnName,
                Progress       = x.Progress,
                Score          = x.Score
            }).AsEnumerable().ToList();


            return(Json(new
            {
                aaData = EmployeeD,
                eEcho = param.sEcho,
                iTotalDisplayRecords = totalCount,
                iTotalRecords = EmployeeD.Count()
            }, JsonRequestBehavior.AllowGet));
        }
Example #12
0
        public ActionResult List(DataTablesParam dataTableParam)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
            {
                return(AccessDeniedView());
            }

            var extendedAttributes = _extendedAttributeService.GetAllExtendedAttributes(true);

            var total  = extendedAttributes.Count();
            var result = new DataTablesData
            {
                iTotalRecords        = total,
                iTotalDisplayRecords = total,
                sEcho  = dataTableParam.sEcho,
                aaData = extendedAttributes.Select(x =>
                {
                    var caModel = x.ToModel();
                    caModel.AttributeControlTypeName = x.AttributeControlType.GetLocalizedEnum(_localizationService, _workContext);
                    return(caModel);
                }).Cast <object>().ToArray(),
            };

            return(new JsonResult
            {
                Data = result
            });
        }
        public JsonResult GetIdiomas(DataTablesParam param)
        {
            int IdentityPersonal = SessionPersister.AccountSession.IdPersonal;
            List <IdiomaDomainModel> alergiasDM = new List <IdiomaDomainModel>();

            int pageNo = 1;

            if (param.iDisplayStart >= param.iDisplayLength)
            {
                pageNo = (param.iDisplayStart / param.iDisplayLength) + 1;
            }

            int totalCount = 0;

            if (param.sSearch != null)
            {
                alergiasDM = IidiomaBusinnes.GetIdiomasByIdPersonal(IdentityPersonal).Where(p => p.strDescripcion.Contains(param.sSearch)).ToList();
            }
            else
            {
                totalCount = IidiomaBusinnes.GetIdiomasByIdPersonal(IdentityPersonal).Count();


                alergiasDM = IidiomaBusinnes.GetIdiomasByIdPersonal(IdentityPersonal).OrderBy(p => p.strDescripcion)
                             .Skip((pageNo - 1) * param.iDisplayLength).Take(param.iDisplayLength).ToList();
            }
            return(Json(new
            {
                aaData = alergiasDM,
                sEcho = param.sEcho,
                iTotalDisplayRecords = alergiasDM.Count(),
                iTotalRecords = alergiasDM.Count()
            }, JsonRequestBehavior.AllowGet));
        }
        public IActionResult getMailArchive(DataTablesParam param)
        {
            int totalNo = 0, recordFilter = 0;
            var obj = mailArchiveService.GetMailArchives(
                param.sSearch,
                param.iDisplayStart,
                param.iDisplayLength,
                out totalNo,
                out recordFilter
                ).ToList();

            var newObj = obj.Select(m => new {
                id       = m.ID,
                mailId   = m.MailId,
                mailType = m.MailType?.MailName,
                postType = m.PostType?.PostName,
                //  classificationType = m.Classification.ClassificationName,
                insertdate = m.InsertDate.Value.ToString("dd/MM/yyy") ?? DateTime.Now.AddYears(-40).ToString("dd/MM/yyy"),
                fromJehaz  = m.FromJehazId?.Text,
                toJehaz    = m.ToJehazId?.Text,
                topic      = m.Topic?.ToString()
            });

            return(Json(new
            {
                data = newObj,
                eEcho = param.sEcho,
                iTotalDisplayRecords = recordFilter,
                iTotalRecords = totalNo
            }));
        }
Example #15
0
        public JsonNetResult DataTables(DataTablesParam p)
        {
            // calculate total results to request from lucene search
            int numResults = (p.iDisplayStart >= 0 && p.iDisplayLength > 0) ? (p.iDisplayStart + 1) * p.iDisplayLength : 10;

            IList <LuceneSearchResult> results = this.luceneTasks.UnitSearch(p.sSearch, numResults);

            int iTotalRecords = 0;

            if (results != null && results.Count > 0)
            {
                iTotalRecords = results.First().TotalHits;
            }

            object[] aaData = results
                              .Select(x => new UnitDataTableLuceneView(x))
                              .Skip(p.iDisplayStart)
                              .Take(p.iDisplayLength)
                              .ToArray <UnitDataTableLuceneView>();

            return(JsonNet(new DataTablesData
            {
                iTotalRecords = iTotalRecords,
                iTotalDisplayRecords = iTotalRecords,
                sEcho = p.sEcho,
                aaData = aaData.ToArray()
            }));
        }
Example #16
0
        public DataTablesResult <RequestView> DataTables(DataTablesParam p)
        {
            IQueryable <Request> q = this.requestTasks.GetRequestsQueryable().Where(x => !x.Archive);

            AdminUser user = this.userTasks.GetAdminUser(User.Identity.Name);

            // a user with only the initiator role and none of the other screening roles can only view selected requests
            if (User.IsInRole(AdminRole.ScreeningRequestInitiator) &&
                !User.IsInRole(AdminRole.ScreeningRequestValidator) &&
                !((PrfPrincipal)User).HasPermission(AdminPermission.CanPerformScreeningInput) &&
                !User.IsInRole(AdminRole.ScreeningRequestConsolidator) &&
                !User.IsInRole(AdminRole.ScreeningRequestFinalDecider) &&
                user.ScreeningEntities.Count == 0)     // being a member of a screening entity allows you to view any request
            {
                q = q.Where(x => x.UserHasPermission(user));
            }

            DataTablesResult <RequestView> result = DataTablesResult.Create(q.Select(x => new RequestView(x)), p, rv => new
            {
                // custom transform for date field - default is to transform datetimes from UTC to local time, but we store
                // dates in local time (this could be rethought).
                CurrentStatusDate = rv.CurrentStatusDate.ToString()
            });

            return(result);
        }
        public JsonResult GetDeportesPersonales(DataTablesParam param)
        {
            int IdentityPersonal = SessionPersister.AccountSession.IdPersonal;
            List <DeportePersonalDomainModel> deportes = new List <DeportePersonalDomainModel>();

            int pageNo = 1;

            if (param.iDisplayStart >= param.iDisplayLength)
            {
                pageNo = (param.iDisplayStart / param.iDisplayLength) + 1;
            }

            int totalCount = 0;

            if (param.sSearch != null)
            {
                deportes = IdeportePersonalBusiness.GetDeportesPersonalesById(IdentityPersonal).Where(p => p.Deporte.StrDescripcion.Contains(param.sSearch)).ToList();
            }
            else
            {
                totalCount = IdeportePersonalBusiness.GetDeportesPersonalesById(IdentityPersonal).Count();

                deportes = IdeportePersonalBusiness.GetDeportesPersonalesById(IdentityPersonal).OrderBy(p => p.IdDeportePersonal)
                           .Skip((pageNo - 1) * param.iDisplayLength).Take(param.iDisplayLength).ToList();
            }
            return(Json(new
            {
                aaData = deportes,
                sEcho = param.sEcho,
                iTotalDisplayRecords = deportes.Count(),
                iTotalRecords = deportes.Count()
            }, JsonRequestBehavior.AllowGet));
        }
Example #18
0
        public JsonResult GetTutorias(DataTablesParam param)
        {
            int IdentityPersonal = SessionPersister.AccountSession.IdPersonal;
            List <TutoriasDomainModel> tutorias = new List <TutoriasDomainModel>();

            int pageNo = 1;

            if (param.iDisplayStart >= param.iDisplayLength)
            {
                pageNo = (param.iDisplayStart / param.iDisplayLength) + 1;
            }

            int totalCount = 0;

            if (param.sSearch != null)
            {
                tutorias = tutoriasBusiness.GetAllTutoriasByIdPersonal(IdentityPersonal).Where(p => p.strNombreEstudantes.Contains(param.sSearch)).ToList();
            }
            else
            {
                totalCount = tutoriasBusiness.GetAllTutoriasByIdPersonal(IdentityPersonal).Count();


                tutorias = tutoriasBusiness.GetAllTutoriasByIdPersonal(IdentityPersonal).OrderBy(p => p.strNombreEstudantes)
                           .Skip((pageNo - 1) * param.iDisplayLength).Take(param.iDisplayLength).ToList();
            }
            return(Json(new
            {
                aaData = tutorias,
                sEcho = param.sEcho,
                iTotalDisplayRecords = tutorias.Count(),
                iTotalRecords = tutorias.Count()
            }, JsonRequestBehavior.AllowGet));
        }
Example #19
0
 public async Task <DataTablesResponseData> GetUserHistory(DataTablesParam model, int userId, int?count)
 {
     using (var context = DataContextFactory.CreateReadOnlyContext())
     {
         var query = context.Prize
                     .Where(p => p.IsClaimed && p.UserId == userId)
                     .Select(x => new
         {
             Id          = x.Id,
             GameId      = x.GameId,
             IsUnclaimed = x.Status == Enums.PrizeStatus.Unclaimed,
             Game        = x.Game.Name,
             Name        = x.Name,
             Description = x.Description,
             X           = x.X,
             Y           = x.Y,
             Points      = x.Points,
             Status      = x.Status,
             Timestamp   = x.ClaimTime,
         });
         if (count.HasValue)
         {
             query = query
                     .OrderBy(x => x.Status)
                     .ThenByDescending(x => x.Timestamp)
                     .Take(count.Value);
         }
         return(await query.GetDataTableResponseAsync(model, disablePaging : count.HasValue));
     }
 }
        public JsonResult GetEstadosDeSaludPersonal(DataTablesParam param)
        {
            int IdentityPersonal = SessionPersister.AccountSession.IdPersonal;
            List <EstadoSaludDomainModel> enfermedades = new List <EstadoSaludDomainModel>();

            int pageNo = 1;

            if (param.iDisplayStart >= param.iDisplayLength)
            {
                pageNo = (param.iDisplayStart / param.iDisplayLength) + 1;
            }

            int totalCount = 0;

            if (param.sSearch != null)
            {
                enfermedades = IestadoSaludBusiness.GetEnfermedadesPersonalById(1).Where(p => p.NombreEnfermedad.Contains(param.sSearch)).ToList();
            }
            else
            {
                totalCount = IestadoSaludBusiness.GetEnfermedadesPersonalById(IdentityPersonal).Count();

                enfermedades = IestadoSaludBusiness.GetEnfermedadesPersonalById(IdentityPersonal).OrderBy(p => p.idEnfermedad)
                               .Skip((pageNo - 1) * param.iDisplayLength).Take(param.iDisplayLength).ToList();
            }
            return(Json(new
            {
                aaData = enfermedades,
                sEcho = param.sEcho,
                iTotalDisplayRecords = enfermedades.Count(),
                iTotalRecords = enfermedades.Count()
            }, JsonRequestBehavior.AllowGet));
        }
Example #21
0
        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());
        }
 public DataTablesResult <UserTableRowViewModel> GetUsers(DataTablesParam dataTableParam)
 {
     return(DataTablesResult.Create(FakeDatabase.Users.Select(user => new UserTableRowViewModel()
     {
         Id = user.Id,
         Name = user.Name,
         Email = user.Email,
         Position = user.Position == null ? "" : user.Position.ToString(),
         Number = user.Number,
         Hired = user.Hired,
         IsAdmin = user.IsAdmin,
         Salary = user.Salary,
         Thumb = "https://randomuser.me/api/portraits/thumb/men/" + user.Id + ".jpg"
     }), dataTableParam,
                                    rowViewModel => new
     {
         Name = "<b>" + rowViewModel.Name + "</b>",
         Hired =
             rowViewModel.Hired == null
                     ? "&lt;pending&gt;"
                     : rowViewModel.Hired.Value.ToShortDateString() + " " +
             rowViewModel.Hired.Value.ToShortTimeString() + " (" +
             FriendlyDateHelper.GetPrettyDate(rowViewModel.Hired.Value) + ") ",
         Thumb = "<img src='" + rowViewModel.Thumb + "' />"
     }));
 }
Example #23
0
        public ActionResult Resources(DataTablesParam dataTableParam, int languageId, string resourceName)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageLanguages))
            {
                return(AccessDeniedView());
            }
            // var languageId = dataTableParam.bQueryModel.Items.FirstOrDefault().Value.ToString().ToInt();
            var language = _languageService.GetLanguageById(languageId);

            var resources = _localizationService
                            .GetResourceValues(languageId, resourceName, true)
                            .OrderBy(x => x.Key)
                            .Where(x => x.Key != "!!___EOF___!!" && x.Value != null)
                            .ToList().AsQueryable();

            if (!resourceName.IsEmpty())
            {
                resources = resources.Where(r => r.Key.Contains(resourceName));
            }
            return(DataTablesResult.Create(resources.Select(x =>
                                                            new LanguageResourceModel()
            {
                LanguageId = languageId,
                LanguageName = language.Name,
                Id = x.Value.Item1,
                Name = x.Key,
                Value = x.Value.Item2.EmptyNull(),
            }), dataTableParam
                                           ));
        }
        public JsonResult GetDocumentos(DataTablesParam param)
        {
            int IdentityPersonal = SessionPersister.AccountSession.IdPersonal;
            List <DocumentosDomainModel> documentosDM = new List <DocumentosDomainModel>();

            int pageNo = 1;

            if (param.iDisplayStart >= param.iDisplayLength)
            {
                pageNo = (param.iDisplayStart / param.iDisplayLength) + 1;
            }

            int totalCount = 0;

            if (param.sSearch != null)
            {
                documentosDM = IdocumentosBusiness.GetDocumetosByIdPersonal(IdentityPersonal).Where(p => p.StrUrl.Contains(param.sSearch)).ToList();
            }
            else
            {
                totalCount = IdocumentosBusiness.GetDocumetosByIdPersonal(IdentityPersonal).Count();


                documentosDM = IdocumentosBusiness.GetDocumetosByIdPersonal(IdentityPersonal).OrderBy(p => p.StrUrl)
                               .Skip((pageNo - 1) * param.iDisplayLength).Take(param.iDisplayLength).ToList();
            }
            return(Json(new
            {
                aaData = documentosDM,
                sEcho = param.sEcho,
                iTotalDisplayRecords = documentosDM.Count(),
                iTotalRecords = documentosDM.Count()
            }, JsonRequestBehavior.AllowGet));
        }
Example #25
0
        public JsonResult GetExperiencias(DataTablesParam param)
        {
            int IdentityPersonal = SessionPersister.AccountSession.IdPersonal;
            List <ExperienciaLaboralExternaDomainModel> experienciaDM = new List <ExperienciaLaboralExternaDomainModel>();

            int pageNo = 1;

            if (param.iDisplayStart >= param.iDisplayLength)
            {
                pageNo = (param.iDisplayStart / param.iDisplayLength) + 1;
            }

            int totalCount = 0;

            if (param.sSearch != null)
            {
                experienciaDM = experienciaLaboralExterna.GetExperienciaLaboralByPersonal(IdentityPersonal).Where(p => p.strInstitucionEmpresa.Contains(param.sSearch)).ToList();
            }
            else
            {
                totalCount = experienciaLaboralExterna.GetExperienciaLaboralByPersonal(IdentityPersonal).Count();


                experienciaDM = experienciaLaboralExterna.GetExperienciaLaboralByPersonal(IdentityPersonal).OrderBy(p => p.strInstitucionEmpresa)
                                .Skip((pageNo - 1) * param.iDisplayLength).Take(param.iDisplayLength).ToList();
            }
            return(Json(new
            {
                aaData = experienciaDM,
                sEcho = param.sEcho,
                iTotalDisplayRecords = experienciaDM.Count(),
                iTotalRecords = experienciaDM.Count()
            }, JsonRequestBehavior.AllowGet));
        }
Example #26
0
        public JsonResult ShowAllOrders(DataTablesParam param)
        {
            ApplicationDbContext _context = new ApplicationDbContext();


            List <OrderViewModel> orderList = new List <OrderViewModel>();

            string userId = User.Identity.GetUserId();

            int totalCount = 0;
            int pageNo     = 1;

            if (param.iDisplayStart >= param.iDisplayLength)
            {
                pageNo = (param.iDisplayStart / param.iDisplayLength) + 1;
            }


            if (param.sSearch != null)
            {
                totalCount = _context.Orders.Include(x => x.OrderStatus).Include(x => x.user).Where(x => x.userID == userId && (x.Id.ToString().Contains(param.sSearch) || x.user.user_Name.ToLower().Contains(param.sSearch.ToLower()) || x.createAt.ToString().Contains(param.sSearch) || x.OrderStatus.statusName.ToLower().Contains(param.sSearch.ToLower()))).Count();
                orderList  = _context.Orders.Include(x => x.OrderStatus).Include(x => x.user)
                             .Where(x => x.userID == userId && (x.Id.ToString().Contains(param.sSearch) || x.user.user_Name.ToLower().Contains(param.sSearch.ToLower()) || x.createAt.ToString().Contains(param.sSearch) || x.OrderStatus.statusName.ToLower().Contains(param.sSearch.ToLower())))

                             .Select(x => new OrderViewModel
                {
                    Id           = x.Id,
                    userName     = x.user.user_Name,
                    orderCreated = x.createAt,
                    orderStatud  = x.OrderStatus.statusName,
                    totalBill    = x.totalBill
                })
                             .OrderBy(x => x.Id).Skip((pageNo - 1) * param.iDisplayLength).Take(param.iDisplayLength).ToList();
            }
            else
            {
                totalCount = _context.Orders.Where(x => x.userID == userId).Count();
                orderList  = _context.Orders.Include(x => x.OrderStatus).Include(x => x.user).Where(x => x.userID.Equals(userId))

                             .Select(x => new OrderViewModel
                {
                    Id           = x.Id,
                    userName     = x.user.user_Name,
                    orderCreated = x.createAt,
                    orderStatud  = x.OrderStatus.statusName,
                    totalBill    = x.totalBill
                }).OrderBy(x => x.Id).Skip((pageNo - 1) * param.iDisplayLength).Take(param.iDisplayLength)
                             .ToList();
            }



            return(Json(new
            {
                aaData = orderList,
                sEcho = param.sEcho,
                iTotalDisplayRecords = totalCount,
                iTotalRecords = totalCount
            }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult GetDatosPersonalAsociacionTable(DataTablesParam param)
        {
            int IdentityPersonal = SessionPersister.AccountSession.IdPersonal;
            List <PersonalAsociacionesDomainModel> personalAsociaciones = new List <PersonalAsociacionesDomainModel>();

            int pageNo = 1;

            if (param.iDisplayStart >= param.iDisplayLength)
            {
                pageNo = (param.iDisplayStart / param.iDisplayLength) + 1;
            }

            int totalCount = 0;

            if (param.sSearch != null)
            {
                personalAsociaciones = IpersonalAsociacionesBusiness.GetPersonalAsociacinesById(IdentityPersonal).Where(p => p.StrTipoParticipacion
                                                                                                                        .Contains(param.sSearch)).ToList();
            }
            else
            {
                totalCount = IpersonalAsociacionesBusiness.GetPersonalAsociacinesById(IdentityPersonal).Count();

                personalAsociaciones = IpersonalAsociacionesBusiness.GetPersonalAsociacinesById(IdentityPersonal).OrderBy(p => p.IdPersonal)
                                       .Skip((pageNo - 1) * param.iDisplayLength).Take(param.iDisplayLength).ToList();
            }
            return(Json(new
            {
                aaData = personalAsociaciones,
                sEcho = param.sEcho,
                iTotalDisplayRecords = personalAsociaciones.Count(),
                iTotalRecords = personalAsociaciones.Count()
            }, JsonRequestBehavior.AllowGet));
        }
Example #28
0
        public JsonResult GetCapacitacionesRecibidas(DataTablesParam param)
        {
            int identityPersonal = SessionPersister.AccountSession.IdPersonal;
            List <CapacitacionesRecibidasDomainModel> capacitacionesRecibidasDomainModels = new List <CapacitacionesRecibidasDomainModel>();


            int pageNo = 1;

            if (param.iDisplayStart >= param.iDisplayLength)
            {
                pageNo = (param.iDisplayStart / param.iDisplayLength) + 1;
            }

            int totalCount = 0;

            if (param.sSearch != null)
            {
                capacitacionesRecibidasDomainModels = capacitacionesRecibidasBusiness.GetCapacitacionesRecibidas(identityPersonal).Where(p => p.strNombre.Contains(param.sSearch)).ToList();
            }
            else
            {
                totalCount = capacitacionesRecibidasBusiness.GetCapacitacionesRecibidas(identityPersonal).Count();

                capacitacionesRecibidasDomainModels = capacitacionesRecibidasBusiness.GetCapacitacionesRecibidas(identityPersonal).OrderBy(p => p.strNombre).Skip((pageNo - 1)
                                                                                                                                                                  * param.iDisplayLength).Take(param.iDisplayLength).ToList();
            }

            return(Json(new
            {
                aaData = capacitacionesRecibidasDomainModels,
                sEcho = param.sEcho,
                iTotalDisplayRecords = capacitacionesRecibidasDomainModels.Count(),
                iTotalRecords = capacitacionesRecibidasDomainModels.Count()
            }, JsonRequestBehavior.AllowGet));
        }
Example #29
0
        public JsonResult GetLibros(DataTablesParam param)
        {
            int identityPersonal             = SessionPersister.AccountSession.IdPersonal;
            List <LibroDomainModel> librosDM = new List <LibroDomainModel>();

            int pageNo = 1;

            if (param.iDisplayStart >= param.iDisplayLength)
            {
                pageNo = (param.iDisplayStart / param.iDisplayLength) + 1;
            }

            int totalCount = 0;

            if (param.sSearch != null)
            {
                librosDM = libroBusiness.GetLibrosByPersonal(identityPersonal).Where(p => p.strTituloLibro.Contains(param.sSearch)).ToList();
            }
            else
            {
                totalCount = libroBusiness.GetLibrosByPersonal(identityPersonal).Count();

                librosDM = libroBusiness.GetLibrosByPersonal(identityPersonal).OrderBy(p => p.strTituloLibro).Skip((pageNo - 1)
                                                                                                                   * param.iDisplayLength).Take(param.iDisplayLength).ToList();
            }

            return(Json(new
            {
                aaData = librosDM,
                sEcho = param.sEcho,
                iTotalDisplayRecords = librosDM.Count(),
                iTotalRecords = librosDM.Count()
            }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult List(DataTablesParam dataTableParam)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageEmailAccounts))
            {
                return(AccessDeniedView());
            }

            var emailAccountModels = _emailAccountService.GetAllEmailAccounts()
                                     .Select(x => x.ToModel())
                                     .ToList();

            foreach (var eam in emailAccountModels)
            {
                eam.IsDefaultEmailAccount = eam.Id == _emailAccountSettings.DefaultEmailAccountId;
            }

            var total  = emailAccountModels.Count();
            var result = new DataTablesData
            {
                iTotalRecords        = total,
                iTotalDisplayRecords = total,
                sEcho  = dataTableParam.sEcho,
                aaData = emailAccountModels.Cast <object>().ToArray(),
            };

            return(new JsonResult
            {
                Data = result
            });
        }
 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;
 }
 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();
 }
        public IDataTablesResult<UserView> GetUsers(DataTablesParam dataTableParam)
        {
            var users = new List<User>
            (
                Enumerable.Range(1, 100).Select(i => new User(){Id = i, Email = "user" + i + "@gmail.com", Name = "User" + i})
            ).AsQueryable();

            return DataTablesResult.Create(users, dataTableParam, user => new UserView()
            {
                Id = user.Id,
                Name = user.Name
            });
        }
        public DataTablesResult<UserView> GetUsers(DataTablesParam dataTableParam)
        {
            var users = Users().AsQueryable();

            return DataTablesResult.Create(users, dataTableParam, user => new UserView()
            {
                Id = user.Id,
                Name = user.Name,
                Email = user.Email,
                Position = user.Position == null ? "" : user.Position.ToString(),
                Hired = user.Hired
            });
        }
        public DataTablesResult<UserView> GetUsers(DataTablesParam dataTableParam)
        {
            var users = Users().AsQueryable();

            return DataTablesResult.Create(users, dataTableParam, user => new UserView()
            {
                Id = user.Id,
                Name = new MvcHtmlString("<b>" + user.Name +"</b>"),
                Email = user.Email,
                Position = user.Position == null ? "" : user.Position.ToString(),
                Number = user.Number,
                Hired = user.Hired,
                IsAdmin = user.IsAdmin
            });
        }
        public DataTablesResult<UserView> GetUsers(DataTablesParam dataTableParam)
        {
            var users = Users().AsQueryable();

            return DataTablesResult.Create(users, dataTableParam, user => new UserView()
            {
                Position = user.Position == null ? "" : user.Position.ToString(),
                Number = user.Number,
                Email = user.Email,
                Name = new MvcHtmlString("<b>" + user.Name + "</b>"),
                Hired = user.Hired,
                someOtherInfo1 = "",
                someOtherInfo2 = "",
                someOtherInfo3 = string.Format("Id is {0}", user.Id)
            });
        }
 public DataTablesResult<UserView> GetUsers(DataTablesParam dataTableParam)
 {
     return DataTablesResult.Create(FakeDatabase.Users.Select(user => new UserView()
     {
         Id = user.Id,
         Name = user.Name,
         Email = user.Email,
         Position = user.Position == null ? "" : user.Position.ToString(),
         Number = user.Number,
         Hired = user.Hired,
         IsAdmin = user.IsAdmin,
         Salary = user.Salary
     }), dataTableParam,
     uv => new 
     {
         Name = "<b>" + uv.Name + "</b>",
         Hired = uv.Hired.ToShortDateString() + " (" + FriendlyDateHelper.GetPrettyDate(uv.Hired) + ") "
     });
 }
 public DataTablesResult<UserView> GetUsers(DataTablesParam dataTableParam)
 {
     return DataTablesResult.Create(FakeDatabase.Users.Select(user => new UserView()
     {
         Id = user.Id,
         Name = user.Name,
         Email = user.Email,
         Position = user.Position == null ? "" : user.Position.ToString(),
         Number = user.Number,
         Hired = user.Hired,
         IsAdmin = user.IsAdmin,
         Salary = user.Salary,
         Thumb = "https://randomuser.me/api/portraits/thumb/men/" + user.Id + ".jpg"
     }), dataTableParam,
     uv => new 
     {
         Name = "<b>" + uv.Name + "</b>",
         Hired = uv.Hired == null ? "&lt;pending&gt;" : uv.Hired.Value.ToShortDateString() + " (" + FriendlyDateHelper.GetPrettyDate(uv.Hired.Value) + ") ",
         Thumb = "<img src='" + uv.Thumb + "' />"
     });
 }
        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));

        }
        public ActionResult Index(DataTablesParam dataTableParam = null)
        {
            if (Request.IsAjaxRequest())
            {
                var cars = db.Cars.AsQueryable();

                // swap out sort fields with ones DynamicLinq will handle.
                var dataTableOptions = new DataTablesOptions();
                dataTableOptions.SearchAliases.Add("Name", "Year");

                return DataTablesResult.Create(cars, dataTableParam, dataTableOptions, oo => new
                {
                    Name = oo.FriendlyName,
                    Year = oo.Year.ToString().Substring(2),
                    Id = oo.Id
                });
            }
            else
            {
                return View();
            }
        }
 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();
 }
        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 GetUsersUntyped(DataTablesParam dataTableParam)
        {
            var users = Users();

            return DataTablesResult.Create(users, dataTableParam);
        }