Esempio n. 1
0
 public ActionResult Index(int ID)
 {
     var model = new CustomerSearchViewModel()
     {
         ID = ID
     };
     return PartialView(model);
 }
Esempio n. 2
0
        public ActionResult getall(CustomerSearchViewModel model, int page = 1, int rows = 10)
        {
            var query = CustomerService.GetALL().Include(x => x.JobCate).Include(x => x.CustomerCompany);

            if (!string.IsNullOrEmpty(model.Customer_SearchName))
            {
                query = query.Where(x => x.Name.Contains(model.Customer_SearchName));
            }

            if (model.ID != 0)
            {
                query = query.Where(x => x.CustomerCompany.ID == model.ID);
            }

            var count = query.Count();

            var data = query.Select(x => new CustomerListViewModel()
            {
                ID = x.ID,

                JobID = x.JobID,

                JobIDName = x.JobCate.CateName,

                CompanyID = x.CompanyID,

                Name = x.Name,

                Mobile = x.Mobile,

                Mobile1 = x.Mobile1,

                Phone = x.Phone,

                AddBirthDay = x.AddBirthDay,

                IsLeap = x.IsLeap,

                BirthDay = x.BirthDay,

                BirthDay1 = x.BirthDay1,

                QQ = x.QQ,

                Jobs = x.Jobs,

                Email = x.Email,

                Favorite = x.Favorite,

                Address = x.Address,

                ReMark = x.ReMark,

                AddTime = x.AddTime,

                LastTime = x.LastTime,

                Status = x.Status,

                AddUser = x.AddUser,

                LastUser = x.LastUser,

            })
            .OrderBy(x => x.ID)
            .Skip((page - 1) * rows)
            .Take(rows).ToList();

            foreach (var item in data)
            {
                if (item.AddBirthDay)
                {
                    if (item.IsLeap)
                    {
                        item.BirthDay1 = Utilities.ConvertToChineseYearStyle(item.BirthDay.Year) + item.BirthDay1;
                    }
                    else
                    {
                        item.BirthDay1 = item.BirthDay.ToString("yyyy-MM-dd");
                    }
                }
                else
                {
                    item.BirthDay1 = "";
                }
            }

            var obj = new
            {
                rows = data,
                total = count
            };
            return Json(obj);
        }