Beispiel #1
0
        public JsonResult GetSellers(string price)
        {
            string auth = AppUserToken;


            JsonResult json = new JsonResult();

            if (auth.IsEmpty())
            {
                //没有登录
                //
                return(json);
            }
            else if (auth == "-1")
            {
                return(json);
            }


            try
            {
                Coupon coupon = CouponClass.getCoupon(auth, Convert.ToInt32(price));
                json.Data = coupon.Result.List.ToList();
            }
            catch { }
            return(json);
        }
        public int PostCoupon(CouponClass RC)
        {
            int check = 0;

            try
            {
                Coupon c = new Coupon();
                c.RestId = RC.RestaurantId;
                c.UserId = RC.UserId;
                c.Expiry = DateTime.Now.ToString();
                obj.Coupons.InsertOnSubmit(c);
                obj.SubmitChanges();
                check = c.Id;
            }
            catch (Exception e) { check = 0; }
            return(check);
        }
        public List <CouponClass> GetCoupon(string id)
        {
            List <CouponClass> li = new List <CouponClass>();
            var res = obj.Restaurants.First(x => x.Name.Equals(id));

            var Ps    = obj.Coupons.Where(x => x.RestId.Equals(res.Id)).ToList();
            var count = Ps.Count();

            foreach (var details in Ps)
            {
                CouponClass temp = new CouponClass();
                temp.RestaurantId = details.RestId.Value;
                temp.UserId       = details.UserId.Value;
                temp.Date         = details.Expiry;
                temp.count        = count;

                li.Add(temp);
            }
            return(li);
        }