Exemple #1
0
        public ActionResult Personal(string id)
        {
            int uid = Convert.ToInt32(id);

            UserUserInfo userUserInfo = UserUserInfoService.LoadEntities(u => u.uid == uid).FirstOrDefault();

            User     user     = UserService.LoadEntities(u => u.uid == userUserInfo.uid).FirstOrDefault();
            UserInfo userInfo = UserInfoService.LoadEntities(u => u.uiid == userUserInfo.uiid).FirstOrDefault();

            ViewBag.user     = user;
            ViewBag.userInfo = userInfo;

            return(View());
        }
        public JsonResult deleteUser(string uid, string uiid)
        {
            //Console.WriteLine();

            int uidInt  = Convert.ToInt32(uid);
            int uiidInt = Convert.ToInt32(uiid);

            UserUserInfo uui = UserUserInfoService.LoadEntities(u => u.uid == uidInt && u.uiid == uiidInt).FirstOrDefault();

            UserUserInfoService.DeleteEntity(uui);

            UserAuth userAuth = UserAuthService.LoadEntities(u => u.uid == uidInt).FirstOrDefault();

            UserAuthService.DeleteEntity(userAuth);
            //UserService.DeleteEntity(user);

            return(Json("success", JsonRequestBehavior.AllowGet));
        }
        public JsonResult getMainData(string province)
        {
            int userToday = 0;
            int userMonth = 0;
            int userHis   = 0;

            DateTime dt  = DateTime.Now;
            string   now = dt.ToString("yyyyMMdd");
            // 用户
            List <UserUserInfo> userList = UserUserInfoService.LoadEntities(u => true).ToList();

            userToday = userList.Where(u => u.pubTime == now).ToList().Count;
            foreach (UserUserInfo item in userList)
            {
                DateTime itemDate = DateTime.ParseExact(item.pubTime, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
                //DateTime _itemDate = itemDate.ToShortDateString();
                DateTime startMonth = DateTime.ParseExact(dt.AddDays(1 - dt.Day).ToString("yyyyMMdd"), "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
                //本月月初 带分钟
                //DateTime _startMonth = DateTime.ParseExact(startMonth.ToShortDateString(), "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
                //DateTime endMonth = startMonth.AddMonths(1).AddDays(-1);  //本月月末
                DateTime endMonth = DateTime.ParseExact(dt.AddDays(1 - dt.Day).AddMonths(1).AddDays(-1).ToString("yyyyMMdd"), "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
                //DateTime _endMonth = DateTime.ParseExact(startMonth.ToShortDateString(), "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
                if (itemDate >= startMonth && itemDate <= endMonth)
                {
                    userMonth++;
                }
            }

            userHis = userList.Count;

            // 订单
            int orderToday  = 0;
            int orderMonth  = 0;
            int orderHis    = 0;
            int waitOrder   = 0;
            int placedOrder = 0;
            List <OrdersUserHouse> ouhList = OrdersUserHouseService.LoadEntities(o => true).ToList();

            orderToday = ouhList.Where(o => o.pubTime == now).ToList().Count;
            foreach (OrdersUserHouse ouh in ouhList)
            {
                Orders order = OrdersService.LoadEntities(o => o.oid == ouh.oid).FirstOrDefault();

                DateTime itemDate = DateTime.ParseExact(ouh.pubTime, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);

                DateTime startMonth = dt.AddDays(1 - dt.Day);              //本月月初
                DateTime endMonth   = startMonth.AddMonths(1).AddDays(-1); //本月月末

                if (itemDate >= startMonth && itemDate <= endMonth)
                {
                    orderMonth++;
                }

                if (order.state == "0")
                {
                    waitOrder++;
                }

                if (order.state == "1")
                {
                    placedOrder++;
                }
            }

            orderHis = ouhList.Count;

            // 房屋
            int          houseToday = 0;
            int          houseMonth = 0;
            int          houseHis   = 0;
            List <House> houseList  = HouseService.LoadEntities(h => true).ToList();

            houseToday = houseList.Where(h => h.time == now).ToList().Count;
            foreach (House item in houseList)
            {
                DateTime itemDate = DateTime.ParseExact(item.time, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);

                DateTime startMonth = dt.AddDays(1 - dt.Day);              //本月月初
                DateTime endMonth   = startMonth.AddMonths(1).AddDays(-1); //本月月末

                if (itemDate >= startMonth && itemDate <= endMonth)
                {
                    houseMonth++;
                }
            }

            houseHis = houseList.Count;


            Dictionary <string, int> userChart  = new Dictionary <string, int>();
            Dictionary <string, int> houseChart = new Dictionary <string, int>();
            DateTime last7Day = DateTime.Now.AddDays(-6);

            for (int i = 0; i <= 6; i++)
            {
                string date = last7Day.ToString("yyyyMMdd");
                //DateTime itemDate = DateTime.ParseExact(date, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
                int count      = UserUserInfoService.LoadEntities(u => u.pubTime == date).ToList().Count;
                int countHouse = HouseService.LoadEntities(h => h.time == date).ToList().Count;
                userChart.Add(date, count);
                houseChart.Add(date, countHouse);
                last7Day = last7Day.AddDays(1);
            }


            houseList = HouseService.LoadEntities(h => h.province == province).ToList();
            Dictionary <string, int> houseDic = new Dictionary <string, int>();

            foreach (House item in houseList)
            {
                if (!houseDic.ContainsKey(item.city))
                {
                    houseDic.Add(item.city, 1);
                }
                else
                {
                    int count = houseDic[item.city] += 1;
                    houseDic[item.city] = count;
                }
            }

            List <string> userChartX = userChart.Keys.ToList();
            List <int>    userChartY = userChart.Values.ToList();

            //List<string> houseDicX = houseDic.Keys.ToList();
            List <int>      houseDicY = houseDic.Values.ToList();
            List <HousePie> housePie  = new List <HousePie>();

            foreach (var item in houseDic)
            {
                housePie.Add(new HousePie {
                    name = item.Key, value = item.Value.ToString()
                });
            }

            List <string>         provinces = new List <string>();
            List <DataDictionary> datas     = DataDictionaryService.LoadEntities(d => d.dkey == "region").ToList();

            foreach (var item in datas)
            {
                if (!provinces.Contains(item.dvalue3))
                {
                    provinces.Add(item.dvalue3);
                }
            }

            AdminMainEntity entity = new AdminMainEntity
            {
                userToday   = userToday,
                userMonth   = userMonth,
                userHis     = userHis,
                orderToday  = orderToday,
                orderMonth  = orderMonth,
                orderHis    = orderHis,
                waitOrder   = waitOrder,
                placedOrder = placedOrder,
                houseToday  = houseToday,
                houseMonth  = houseMonth,
                houseHis    = houseHis,
                userChartX  = userChartX,
                userChartY  = userChartY,
                //houseDicX = houseDicX,
                houseDicY = houseChart.Values.ToList(),
                housePie  = housePie,
                provinces = provinces
            };

            return(Json(entity, JsonRequestBehavior.AllowGet));
        }
        public JsonResult getOrders(string pageSize, string page,
                                    string name,
                                    string oid,
                                    string community,
                                    string area,
                                    string unitType,
                                    string duration,
                                    string rent,
                                    string floor,
                                    string time,
                                    string state

                                    )
        {
            List <OrdersUserHouse> ouhList = OrdersUserHouseService.LoadEntities(o => true).ToList();

            List <OrdersUserHouseEntity> entity = new List <OrdersUserHouseEntity>();

            foreach (OrdersUserHouse item in ouhList)
            {
                Orders orders = OrdersService.LoadEntities(o => o.oid == item.oid).FirstOrDefault();
                User   user   = UserService.LoadEntities(o => o.uid == item.uid).FirstOrDefault();

                int      uiid     = UserUserInfoService.LoadEntities(u => u.uid == user.uid).FirstOrDefault().uiid;
                UserInfo userInfo = UserInfoService.LoadEntities(u => u.uiid == uiid).FirstOrDefault();
                House    house    = HouseService.LoadEntities(h => h.hid == item.hid).FirstOrDefault();

                entity.Add(new OrdersUserHouseEntity()
                {
                    name      = userInfo.name,
                    phone     = userInfo.phone,
                    duration  = orders.duration,
                    rent      = orders.rent,
                    state     = orders.state,
                    time      = orders.time,
                    ouhid     = item.ouhid,
                    hid       = house.hid,
                    community = house.community,
                    unitType  = house.unitType,
                    area      = house.area,
                    oid       = orders.oid,
                    floor     = house.floor
                });
            }

            int pageInt     = Convert.ToInt32(page);
            int pageSizeInt = Convert.ToInt32(pageSize);


            if (!string.IsNullOrWhiteSpace(state))
            {
                //int oidInt = Convert.ToInt32(oid);
                entity = entity.Where(u => u.state == state).ToList();
            }

            //time = time.Replace("-","");
            // 20210326
            if (!string.IsNullOrWhiteSpace(time))
            {
                time = time.Substring(0, 10).Replace("-", "");
                DateTime itemDate = DateTime.ParseExact(time, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
                itemDate = itemDate.AddDays(1);
                string formatDate = itemDate.ToString("yyyyMMdd");
                //int oidInt = Convert.ToInt32(oid);
                entity = entity.Where(u => u.time == formatDate).ToList();
            }


            if (!string.IsNullOrWhiteSpace(oid))
            {
                int oidInt = Convert.ToInt32(oid);
                entity = entity.Where(u => u.oid == oidInt).ToList();
            }


            if (!string.IsNullOrWhiteSpace(area))
            {
                int areaInt = Convert.ToInt32(area);
                entity = entity.Where(u => u.area == areaInt).ToList();
            }

            if (!string.IsNullOrWhiteSpace(duration))
            {
                int durationInt = Convert.ToInt32(duration);
                entity = entity.Where(u => u.duration == durationInt).ToList();
            }

            if (!string.IsNullOrWhiteSpace(rent))
            {
                int rentInt = Convert.ToInt32(rent);
                entity = entity.Where(u => u.rent == rentInt).ToList();
            }

            if (!string.IsNullOrWhiteSpace(name))
            {
                entity = entity.Where(u => u.name.Contains(name)).ToList();
            }

            if (!string.IsNullOrWhiteSpace(community))
            {
                entity = entity.Where(u => u.community.Contains(community)).ToList();
            }


            if (!string.IsNullOrWhiteSpace(unitType))
            {
                entity = entity.Where(u => u.unitType.Contains(unitType)).ToList();
            }


            if (!string.IsNullOrWhiteSpace(floor))
            {
                entity = entity.Where(u => u.floor.Contains(floor)).ToList();
            }


            int total = entity.Count;

            entity = entity.Skip((pageInt - 1) * pageSizeInt).Take(pageSizeInt).ToList();


            return(Json(new { entity = entity, total = total }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult getUser(
            string pageSize,
            string name,
            string page,
            string username,
            string password,
            string phone,
            string sex,
            string isSys)
        {
            List <UserUserInfo> uuiList = UserUserInfoService.LoadEntities(t => true).ToList();

            List <UserUserInfoEntity> entity = new List <UserUserInfoEntity>();

            foreach (UserUserInfo item in uuiList)
            {
                User     user     = UserService.LoadEntities(u => u.uid == item.uid).FirstOrDefault();
                UserInfo userInfo = UserInfoService.LoadEntities(u => u.uiid == item.uiid).FirstOrDefault();
                entity.Add(new UserUserInfoEntity
                {
                    uid      = user.uid,
                    uiid     = userInfo.uiid,
                    username = user.username,
                    password = user.password,
                    name     = userInfo.name,
                    sex      = userInfo.sex,
                    phone    = userInfo.phone,
                    isSys    = user.isSys
                });
            }

            int pageInt     = Convert.ToInt32(page);
            int pageSizeInt = Convert.ToInt32(pageSize);

            if (!string.IsNullOrEmpty(name))
            {
                entity = entity.Where(u => u.name.Contains(name)).ToList();
            }

            if (!string.IsNullOrWhiteSpace(username))
            {
                entity = entity.Where(u => u.username.Contains(username)).ToList();
            }

            if (!string.IsNullOrWhiteSpace(isSys))
            {
                entity = entity.Where(u => u.isSys == isSys).ToList();
            }

            if (!string.IsNullOrWhiteSpace(password))
            {
                entity = entity.Where(u => u.password.Contains(password)).ToList();
            }


            if (!string.IsNullOrWhiteSpace(sex))
            {
                entity = entity.Where(u => u.sex == sex).ToList();
            }


            if (!string.IsNullOrWhiteSpace(phone))
            {
                entity = entity.Where(u => u.phone.Contains(phone)).ToList();
            }
            int total = entity.Count;

            entity = entity.Skip((pageInt - 1) * pageSizeInt).Take(pageSizeInt).ToList();

            return(Json(new { entity = entity, total = total }, JsonRequestBehavior.AllowGet));
        }