예제 #1
0
        public ActionResult CreateNewUserOrder()
        {
            ShopModel sm = new ShopModel();
            UserModel um = new UserModel();

            int availableOrderId = sm.GetAvailableUserOrderId();

            if(availableOrderId != -1)
                return Json(new { status = 0, msg = availableOrderId }, JsonRequestBehavior.AllowGet);

            UserOrder order = new UserOrder();

            UserInfo userInfo = um.GetUserInfo(User.Identity.Name);
            order.Available = true;
            order.CreateBy = userInfo.Id;
            order.CreateTime = DateTime.Now;
            try
            {
                sm.Add(order);
            }
            catch(Exception ex)
            {
                return Json(new { status = 0, msg = ex.Message }, JsonRequestBehavior.AllowGet);
            }

            return Json(new { status = 1, msg = order.Id }, JsonRequestBehavior.AllowGet);
        }
예제 #2
0
 /// <summary>
 /// 用于向 UserOrder EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToUserOrder(UserOrder userOrder)
 {
     base.AddObject("UserOrder", userOrder);
 }
예제 #3
0
 public void Add(UserOrder order)
 {
     db.UserOrder.AddObject(order);
     Save();
 }
예제 #4
0
 /// <summary>
 /// 创建新的 UserOrder 对象。
 /// </summary>
 /// <param name="id">Id 属性的初始值。</param>
 /// <param name="available">Available 属性的初始值。</param>
 /// <param name="createBy">CreateBy 属性的初始值。</param>
 /// <param name="createTime">CreateTime 属性的初始值。</param>
 public static UserOrder CreateUserOrder(global::System.Int32 id, global::System.Boolean available, global::System.Int32 createBy, global::System.DateTime createTime)
 {
     UserOrder userOrder = new UserOrder();
     userOrder.Id = id;
     userOrder.Available = available;
     userOrder.CreateBy = createBy;
     userOrder.CreateTime = createTime;
     return userOrder;
 }