Пример #1
0
        public ReturnMessage Carsell(dynamic _in)
        {
            ReturnMessage result = new ReturnMessage();
            string        inId   = _in.car_id;
            string        inVin  = _in.car_vin;

            // 二手车id已存在
            var sId = from m in dbContext.car_data
                      where m.car_id == inId
                      select m;

            if (sId.FirstOrDefault() != null)
            {
                result.code    = 0;
                result.message = "二手车id已存在";
                return(result);
            }

            // 车架号存在
            var sVin = from m in dbContext.car_vin_data
                       where m.car_vin == inVin
                       select m;

            if (sVin.FirstOrDefault() != null)
            {
                result.code    = 0;
                result.message = "二手车车架号已存在";
                return(result);
            }

            // 上架成功
            car_data newCarData = new car_data
            {
                car_id        = _in.car_id,
                car_vin       = _in.car_vin,
                car_condition = _in.car_condition,
                date_buyin    = _in.date_buyin,
                accident      = _in.accident,
                price         = _in.price,
                phone         = _in.phone,
                user_id       = _in.user_id
            };
            car_vin_data newCarVinData = new car_vin_data
            {
                car_vin      = _in.car_vin,
                brand        = _in.brand,
                car_name     = _in.car_name,
                color        = _in.color,
                displacement = _in.displacement,
                date_produce = _in.date_produce
            };

            dbContext.car_vin_data.Add(newCarVinData);
            dbContext.SaveChanges();
            dbContext.car_data.Add(newCarData);
            dbContext.SaveChanges();
            result.code    = 1;
            result.message = "上架成功";
            return(result);
        }
Пример #2
0
        public dataReturnMessage Vip(string vid)
        {
            dataReturnMessage result = new dataReturnMessage();

            // 用户id不存在
            var sUid = from m in dbContext.user_data
                       where m.user_id == vid
                       select m;

            if (sUid.FirstOrDefault() == null)
            {
                result.code    = 0;
                result.message = "用户id不存在";
                result.data    = null;
                return(result);
            }

            // 用户不是vip
            var sVipId = from m in dbContext.vip_data
                         where m.vip_id == vid
                         select m;

            if (sVipId.FirstOrDefault() == null)
            {
                result.code    = 0;
                result.message = "用户不是vip";
                result.data    = null;
                return(result);
            }
            vip_data  vip  = sVipId.First();
            user_data user = sUid.First();
            // 用户vip过期
            DateTime nowTime = DateTime.Now;

            if (Convert.ToDateTime(vip.end_time) < nowTime)
            {
                result.code    = 0;
                result.message = "vip已过期";
                dbContext.vip_data.Remove(vip);
                dbContext.SaveChanges();
                return(result);
            }
            // 查询成功
            result.code    = 1;
            result.message = "查询成功";
            vipReturnData data = new vipReturnData {
                vip_id = vid, user_name = user.user_name, start_time = vip.begin_time, end_time = vip.end_time, vip_level = vip.vip_level
            };

            result.data = data;
            return(result);
        }
Пример #3
0
        public ReturnMessage UidPut(dynamic _in)
        {
            ReturnMessage result = new ReturnMessage();
            string        inUid  = _in.user_id;
            string        inName = _in.user_name;

            // 用户id不存在
            var sUid = from m in dbContext.user_data
                       where m.user_id == inUid
                       select m;

            if (sUid.FirstOrDefault() == null)
            {
                result.code    = 0;
                result.message = "用户id不存在";
                return(result);
            }

            // 用户昵称重复
            var sName = from m in dbContext.user_data
                        where m.user_name == inName
                        select m;

            if (sName.FirstOrDefault() != null)
            {
                if (sName.First().user_id != inUid)
                {
                    result.code    = 0;
                    result.message = "用户昵称重复";
                    return(result);
                }
            }

            // 修改成功
            user_data newData = sUid.First();

            newData.password  = _in.password;
            newData.user_name = inName;
            newData.gender    = _in.gender;
            newData.city      = _in.city;
            dbContext.user_data.Update(newData);
            dbContext.SaveChanges();

            result.code    = 1;
            result.message = "修改成功";
            return(result);
        }
Пример #4
0
        public ReturnMessage Carbuy(dynamic _in)
        {
            ReturnMessage result  = new ReturnMessage();
            string        inBuyId = _in.buy_id;
            string        inUid   = _in.user_id;

            // 求购id已存在
            var sBuyId = from m in dbContext.buying_leads
                         where m.buy_id == inBuyId
                         select m;

            if (sBuyId.FirstOrDefault() != null)
            {
                result.code    = 0;
                result.message = "求购id已存在";
                return(result);
            }

            // 用户id不存在
            var sUid = from m in dbContext.user_data
                       where m.user_id == inUid
                       select m;

            if (sUid.FirstOrDefault() == null)
            {
                result.code    = 0;
                result.message = "用户id不存在";
                return(result);
            }

            // 发布求购信息成功
            buying_leads newBuyingLeads = new buying_leads
            {
                buy_id        = _in.buy_id,
                user_id       = _in.user_id,
                brand         = _in.brand,
                car_name      = _in.car_name,
                color         = _in.color,
                displacement  = _in.displacement,
                car_condition = _in.car_condition,
                date_produce  = _in.date_produce,
                accident      = _in.accident,
                price         = _in.price,
                phone         = _in.phone
            };

            dbContext.buying_leads.Add(newBuyingLeads);
            dbContext.SaveChanges();

            result.code    = 1;
            result.message = "发布成功";
            return(result);
        }
Пример #5
0
        public ReturnMessage register(dynamic _in)
        {
            ReturnMessage result = new ReturnMessage();
            string        inUid  = _in.user_id;
            string        inName = _in.user_name;

            var sId = from m in dbContext.user_data
                      where m.user_id == inUid
                      select m;

            // 有重复id
            if (sId.FirstOrDefault() != null)
            {
                result.code    = 0;
                result.message = "用户id重复";
                return(result);
            }

            var sName = from m in dbContext.user_data
                        where m.user_name == inName
                        select m;

            // 有重复name
            if (sName.FirstOrDefault() != null)
            {
                result.code    = 0;
                result.message = "用户名重复";
                return(result);
            }

            user_data newData = new user_data {
                user_id = _in.user_id, password = _in.password, user_name = _in.user_name, gender = _in.gender, city = _in.city
            };

            dbContext.user_data.Add(newData);
            dbContext.SaveChanges();
            result.code    = 1;
            result.message = "注册成功";
            return(result);
        }