コード例 #1
0
        public ActionResult PeopleSearch(int?SenderId, string LampId, string PersonName, int?PersonId, int?DeptId, int?RankId, DateTime?ReportForTime, WorkPlace?WorkPlace)
        {
            var model = new PeopleSearchModel();

            if (Request.Form.Count == 0)
            {
                PopulatePeopleSearchListItems(model);
                return(View(model));
            }

            var criteria = new PeopleSearchCriteria {
                SenderId      = SenderId,
                LampId        = LampId,
                PersonName    = PersonName,
                PersonId      = PersonId,
                DeptId        = DeptId,
                RankId        = RankId,
                ReportForTime = ReportForTime,
                WorkPlace     = WorkPlace.Value
            };
            var list = _dao.GetPeopleSearchReport(criteria);

            model.ReportItems = list;
            if (Request.IsAjaxRequest())
            {
                return(PartialView("PeopleSearchList", model));
            }
            else
            {
                PopulatePeopleSearchListItems(model);
            }
            return(View(model));
        }
コード例 #2
0
        public async Task <IActionResult> GetAll([FromQuery] PeopleSearchCriteria criteria, [FromQuery] Pager pager)
        {
            var peoples = await this.uow.STD_PeopleRepository.GetPagedList(criteria, pager);

            var pages = peoples.ToPagedDTO <STD_People, STD_People>(mapper);

            return(Ok(pages));
        }
コード例 #3
0
        public List <PeopleSearchReportItem> GetPeopleSearchReport(PeopleSearchCriteria criteria)
        {
            var    paramNames   = new List <string>();
            var    paramObjects = new List <SqlParameter>();
            int    i            = 0;
            string p;

            if (criteria.SenderId.HasValue)
            {
                p = "@p" + i++.ToString();
                paramNames.Add("@senderId = " + p);
                paramObjects.Add(new SqlParameter(p, criteria.SenderId.Value));
            }
            if (!string.IsNullOrEmpty(criteria.LampId))
            {
                p = "@p" + i++.ToString();
                paramNames.Add("@lampId = " + p);
                paramObjects.Add(new SqlParameter(p, criteria.LampId));
            }
            if (!string.IsNullOrEmpty(criteria.PersonName))
            {
                p = "@p" + i++.ToString();
                paramNames.Add("@peopleName = " + p);
                paramObjects.Add(new SqlParameter(p, criteria.PersonName));
            }
            if (criteria.PersonId.HasValue)
            {
                p = "@p" + i++.ToString();
                paramNames.Add("@peopleId = " + p);
                paramObjects.Add(new SqlParameter(p, criteria.PersonId));
            }
            if (criteria.DeptId.HasValue)
            {
                p = "@p" + i++.ToString();
                paramNames.Add("@deptId = " + p);
                paramObjects.Add(new SqlParameter(p, criteria.DeptId.Value));
            }
            if (criteria.RankId.HasValue)
            {
                p = "@p" + i++.ToString();
                paramNames.Add("@rankId = " + p);
                paramObjects.Add(new SqlParameter(p, criteria.RankId.Value));
            }
            if (criteria.ReportForTime.HasValue)
            {
                p = "@p" + i++.ToString();
                paramNames.Add("@forTime = " + p);
                paramObjects.Add(new SqlParameter(p, criteria.ReportForTime.Value));
            }
            if (criteria.WorkPlace != WorkPlace.Any)
            {
                p = "@p" + i++.ToString();
                paramNames.Add("@isInWell = " + p);
                paramObjects.Add(new SqlParameter(p, criteria.WorkPlace == WorkPlace.Well));
            }

            var query = context.Database.SqlQuery <PeopleSearchReportItem>("spPeopleSearch " + string.Join(", ", paramNames.ToArray()), paramObjects.ToArray());
            var list  = query.ToList();

            //Assign indexes
            int index = 1;

            list.ForEach(x => x.Index = index++);

            return(list);
        }