コード例 #1
0
        public ActionResult IndexData(DafIndexModelFilter model)
        {
            TryUpdateModel(model, "Filter");
            var filter = model;


            var source = from a in this.DafRepository.Query()
                         select new
            {
                a.Id,
                SerId = a.Client.Agency.GroupId,
                a.Client.AgencyId,
                a.ClientId,
                ClientFirstName = a.Client.FirstName,
                ClientLastName  = a.Client.LastName,
                ClientName      = a.Client.FirstName + " " + a.Client.LastName,
                a.StatusId,
                StatusName = a.StatusId == (int)Daf.Statuses.Open ? Resources.Resource.DafStatusOpen :
                             a.StatusId == (int)Daf.Statuses.EvaluatorSigned ? Resources.Resource.DafStatusSigned :
                             a.StatusId == (int)Daf.Statuses.Completed ? Resources.Resource.DafStatusCompleted :
                             (string)null,
                a.CreatedAt,
                a.UpdateAt,
                EvaluatorName = a.Evaluator.FirstName + " " + a.Evaluator.LastName
            };
            var filtered = from a in source
                           where filter.SerId == null || filter.SerId == a.SerId
                           where filter.AgencyId == null || filter.AgencyId == a.AgencyId
                           where filter.DafId == null || a.Id == filter.DafId
                           where filter.ClientId == null || a.ClientId == filter.ClientId
                           where filter.FirstName == null || a.ClientFirstName.Trim() == filter.FirstName.Trim()
                           where filter.LastName == null || a.ClientLastName.Trim() == filter.LastName.Trim()
                           where filter.Status == null || a.StatusId == (int?)filter.Status
                           where filter.Search == null ||
                           (a.ClientName).Contains(filter.Search) ||
                           (a.EvaluatorName).Contains(filter.Search)
                           select new DafIndexRowModel
            {
                DafId         = a.Id,
                ClientId      = a.ClientId,
                ClientName    = a.ClientName,
                StatusName    = a.StatusName,
                Created       = a.CreatedAt,
                Updated       = a.UpdateAt,
                EvaluatorName = a.EvaluatorName
            };
            var result = new CC.Web.Models.jQueryDataTableResult()
            {
                aaData               = filtered.OrderByField(model.sSortCol_0, model.sSortDir_0 == "asc").Skip(model.iDisplayStart).Take(model.iDisplayLength),
                sEcho                = model.sEcho,
                iTotalRecords        = source.Count(),
                iTotalDisplayRecords = filtered.Count()
            };

            return(this.MyJsonResult(result));
        }
コード例 #2
0
        public JsonResult IndexData(int?RegionId, int?CountryId, int?AgencyGroupId, int?AgencyId, jQueryDataTableParamModel p)
        {
            var usersModel = new UsersModel();
            var source     = usersModel.GetUsers(db, this.Permissions);

            var sSortCol_0 = Request["mDataProp_" + p.iSortCol_0];
            var bSortAsc_0 = p.sSortDir_0 == "asc";

            var filtered = source;

            if (RegionId.HasValue)
            {
                filtered = filtered.Where(f => f.RegionId == RegionId);
            }

            if (CountryId.HasValue)
            {
                filtered = filtered.Where(f => f.CountryId == CountryId);
            }

            if (AgencyGroupId.HasValue)
            {
                filtered = filtered.Where(f => f.AgencyGroupId == AgencyGroupId);
            }

            if (AgencyId.HasValue)
            {
                filtered = filtered.Where(f => f.AgencyId == AgencyId);
            }

            if (!string.IsNullOrEmpty(p.sSearch))
            {
                filtered = filtered.Where(f => System.Data.Objects.SqlClient.SqlFunctions.StringConvert((decimal)f.Id).Trim().Equals(p.sSearch) ||
                                          f.Username.Contains(p.sSearch) ||
                                          f.Role.Contains(p.sSearch) ||
                                          f.RoleEnd.Contains(p.sSearch)
                                          );
            }

            var data = filtered.OrderByField(sSortCol_0, bSortAsc_0).Skip(p.iDisplayStart).Take(p.iDisplayLength);

            var result = new CC.Web.Models.jQueryDataTableResult()
            {
                aaData               = data,
                sEcho                = p.sEcho,
                iTotalRecords        = source.Count(),
                iTotalDisplayRecords = filtered.Count()
            };

            return(this.MyJsonResult(result));
        }
コード例 #3
0
        public JsonResult IndexData(int clientId, CC.Web.Models.jQueryDataTableParamModel p)
        {
            CheckPermissions(clientId);
            var source = from ag in db.ClientContacts
                         where ag.ClientId == clientId
                         select new
            {
                Id                   = ag.Id,
                DateOfContact        = ag.ContactDate,
                Contacted            = ag.Contacted,
                ContactedUsing       = ag.ContactedUsing,
                CcStaffContact       = ag.CcStaffContact,
                ReasonForContact     = ag.ReasonForContact,
                ResponseRecievedDate = ag.ResponseRecievedDate,
                EntryDate            = ag.EntryDate,
                UserName             = ag.User.UserName,
                DocumentName         = ag.Filename
            };

            var sSortCol_0 = Request["mDataProp_" + p.iSortCol_0];
            var bSortAsc_0 = p.sSortDir_0 == "asc";

            var filtered = source;

            if (!string.IsNullOrEmpty(p.sSearch))
            {
                filtered = filtered.Where(f => System.Data.Objects.SqlClient.SqlFunctions.StringConvert((decimal)f.Id).Trim().Equals(p.sSearch));
            }

            var data = filtered.OrderByField(sSortCol_0, bSortAsc_0).Skip(p.iDisplayStart).Take(p.iDisplayLength);

            var result = new CC.Web.Models.jQueryDataTableResult()
            {
                aaData               = data,
                sEcho                = p.sEcho,
                iTotalRecords        = source.Count(),
                iTotalDisplayRecords = filtered.Count()
            };

            return(this.MyJsonResult(result));
        }
コード例 #4
0
        public ActionResult IndexData(DeletedDafIndexModel model)
        {
            TryUpdateModel(model, "Filter");
            var filter = model;

            var source   = QueryDetails();
            var filtered = from a in source
                           where filter.SerId == null || filter.SerId == a.AgencyGroupId
                           where filter.AgencyId == null || filter.AgencyId == a.AgencyId
                           where filter.ClientId == null || a.ClientId == filter.ClientId
                           where filter.FirstName == null || a.ClientFirstName.Trim() == filter.FirstName.Trim()
                           where filter.LastName == null || a.ClientLastName.Trim() == filter.LastName.Trim()
                           where filter.Status == null || a.StatusId == (int?)filter.Status
                           where filter.DeletedFrom == null || a.DeletedAt >= filter.DeletedFrom
                           where filter.DeletedTo == null || a.DeletedAt < filter.DeletedTo
                           where filter.Search == null ||
                           (a.ClientName).Contains(filter.Search) ||
                           (a.EvaluatorName).Contains(filter.Search)
                           select new DeletedDafListRowModel
            {
                DeletedAt     = a.DeletedAt,
                DafId         = a.Id,
                ClientId      = a.ClientId,
                ClientName    = a.ClientName,
                StatusName    = a.StatusName,
                CreatedAt     = a.CreatedAt,
                UpdatedAt     = a.UpdatedAt,
                Updated       = a.UpdatedAt,
                EvaluatorName = a.EvaluatorName
            };
            var result = new CC.Web.Models.jQueryDataTableResult()
            {
                aaData               = filtered.OrderByField(model.sSortCol_0, model.sSortDir_0 == "asc").Skip(model.iDisplayStart).Take(model.iDisplayLength),
                sEcho                = model.sEcho,
                iTotalRecords        = source.Count(),
                iTotalDisplayRecords = filtered.Count()
            };

            return(this.MyJsonResult(result));
        }