예제 #1
0
        public ActionResult PreviewData(Guid id, CC.Web.Models.jQueryDataTableParamModel jq)
        {
            var model  = new CC.Web.Areas.Admin.Models.AppsImportModel(id);
            var result = model.GetPreview(this.db, jq);

            return(this.MyJsonResult(result));
        }
예제 #2
0
        public JsonResult PreviewData(Guid id, CC.Web.Models.jQueryDataTableParamModel jq)
        {
            CheckImportIdPermissions(id);

            using (var db = new ccEntities())
            {
                var HomeCareEntitledPeriods = db.HomeCareEntitledPeriods;
                var ImportHceps             = db.ImportHceps;
                var q        = PreviewDataQuery(id, db, HomeCareEntitledPeriods, ImportHceps);
                var filtered = q;
                var sorted   = filtered.OrderByDescending(f => f.Errors.Count());
                if (jq.iSortCol_0 != 1)
                {
                    sorted = filtered.OrderByField(Request["mDataProp_" + jq.iSortCol_0], jq.sSortDir_0 == "asc");
                }
                if (Request["iSortCol_1"] != null && jq.iSortCol_0 != 1)
                {
                    sorted = sorted.ThenByField(Request["mDataProp_" + Request["iSortCol_1"]], Request["sSortDir_1"] == "asc");
                }
                if (Request["iSortCol_2"] != null && jq.iSortCol_0 != 1)
                {
                    sorted = sorted.ThenByField(Request["mDataProp_" + Request["iSortCol_2"]], Request["sSortDir_2"] == "asc");
                }

                var result = new jQueryDataTableResult()
                {
                    sEcho = jq.sEcho,
                    iTotalDisplayRecords = filtered.Count(),
                    iTotalRecords        = q.Count(),
                    aaData = sorted.Skip(jq.iDisplayStart).Take(jq.iDisplayLength).ToList()
                };
                return(this.MyJsonResult(result, JsonRequestBehavior.AllowGet));
            }
        }
        public JsonResult PreviewMasterIds(Guid id, CC.Web.Models.jQueryDataTableParamModel jq)
        {
            var source = from i in db.ImportClients
                         where i.ImportId == id
                         join c in db.Clients on i.ClientId equals c.Id into cg
                         from c in cg.DefaultIfEmpty()
                         join nm in db.Clients on i.MasterId equals nm.Id into nmg
                         from nm in nmg.DefaultIfEmpty()
                         join om in db.Clients on c.MasterId equals om.Id into omg
                         from om in omg.DefaultIfEmpty()
                         select new
            {
                ClientId  = i.ClientId,
                FirstName = c.FirstName,
                LastName  = c.LastName,

                MasterId               = i.MasterId,
                NewMasterFirstName     = nm.FirstName,
                NewMasterLastName      = nm.LastName,
                CurrentMasterId        = c.MasterId,
                CurrentMasterFirstName = om.FirstName,
                CurrentMasterLastName  = om.LastName
            };

            var filtered = source;

            if (jq.sSearch != null)
            {
                foreach (var s in jq.sSearch.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    filtered = filtered.Where(f =>
                                              System.Data.Objects.SqlClient.SqlFunctions.StringConvert((double?)f.ClientId).Contains(s) ||
                                              f.FirstName.Contains(s) ||
                                              f.LastName.Contains(s));
                }
            }

            var sortCol = Request["mDataProp_" + jq.iSortCol_0.ToString()];
            var sorted  = filtered.OrderByField(sortCol, jq.sSortDir_0 == "asc");

            return(this.MyJsonResult(new jQueryDataTableResult
            {
                aaData = sorted.Skip(jq.iDisplayStart).Take(jq.iDisplayLength).ToList(),
                iTotalDisplayRecords = filtered.Count(),
                iTotalRecords = source.Count(),
                sEcho = jq.sEcho
            }));
        }
        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));
        }