예제 #1
0
        public PagedList<PigHouseModel> GetPigHousePagedList(int pageIndex, int pageSize)
        {
            var pigHouseService = new PigHouseService();
            List<pig_house> pigHouses = pigHouseService.FindAll();
            List<PigHouseModel> pigHouseModels = pigHouses.Select(pigHouse => new PigHouseModel
                                                                                  {
                                                                                      PigHouseTypeId =
                                                                                          pigHouse.PigHouseTypeId,
                                                                                      Number = pigHouse.Number,
                                                                                      Rfid = pigHouse.RFID,
                                                                                      Memo = pigHouse.Memo,
                                                                                      PigHouseTypeName =
                                                                                          pigHouse.pig_house_type.Name
                                                                                  })
                                                          .OrderBy(m => m.Number)
                                                          .OrderBy(m => m.PigHouseTypeName)
                                                          .ToList();
            int count = (pageIndex - 1)*pageSize;

            return new PagedList<PigHouseModel>(pigHouseModels.Skip(count).Take(pageSize), pageIndex, pageSize,
                                                pigHouseModels.Count());
        }
예제 #2
0
 /// <summary>
 ///     猪舍id为1猪栏下拉列表
 /// </summary>
 /// <returns></returns>
 public IEnumerable<SelectListItem> GetFirstPigstyList()
 {
     var pigHouseService = new PigHouseService();
     var pigstyService = new PigstyService();
     IEnumerable<SelectListItem> pigstySelect = new List<SelectListItem>();
     pig_house firstOrDefault = pigHouseService.FindAll().FirstOrDefault();
     if (firstOrDefault != null)
     {
         pigstySelect =
             pigstyService.FindByPigHouseId(firstOrDefault.Id).OrderBy(m=>m.Number).Select(
                 pigstyItem => new SelectListItem
                                   {
                                       Text = pigstyItem.Number + "",
                                       Value = pigstyItem.Id + ""
                                   });
     }
     return pigstySelect;
 }
예제 #3
0
 /// <summary>
 ///     获得猪舍下拉列表
 /// </summary>
 /// <returns>返回集合</returns>
 public IEnumerable<SelectListItem> GetPigHouseList()
 {
     var pigHouseSelect = new PigHouseService();
     IEnumerable<SelectListItem> pigHouseSelectList =
         pigHouseSelect.FindAll().Select(pigHouseItem => new SelectListItem
                                                             {
                                                                 Text = pigHouseItem.pig_house_type.Name +
                                                                        pigHouseItem.Number,
                                                                 Value = pigHouseItem.Id + string.Empty
                                                             }).OrderBy(m => m.Text);
     return pigHouseSelectList;
 }
예제 #4
0
 /// <summary>
 ///     猪栏id为1的猪下拉列表
 /// </summary>
 /// <returns></returns>
 public IEnumerable<SelectListItem> GetFirstPigList()
 {
     var pigHouseService = new PigHouseService();
     var pigstyService = new PigstyService();
     var transferService = new TransferService();
     var pigSelect = new List<SelectListItem>();
     pig_house pigHouse = pigHouseService.FindAll().FirstOrDefault();
     if (pigHouse != null)
     {
         pigsty pigsty = pigstyService.FindByPigHouseId(pigHouse.Id).FirstOrDefault();
         if (pigsty != null)
         {
             string[] strPig = transferService.GetPigIdAndNum(pigsty.Id).Split(',');
             if (strPig[0] != "")
                 pigSelect.AddRange(
                     strPig.Select(strPigItem => strPigItem.Split(':')).Select(pig => new SelectListItem
                                                                                          {
                                                                                              Text = pig[1],
                                                                                              Value = pig[0]
                                                                                          }).OrderBy(m => m.Text));
         }
     }
     return pigSelect;
 }