public int checkyuyue(long lid) { long userid = (long)Session["LoginUserId"]; long guideid = GuideLineSvc.GetGid(lid); var guide = GuideSvc.GetById(guideid); if (guide != null) { if (guide.Users_Id == userid) { return(1); } if (guide.isappointment) { return(2); } } else { return(4); } long[] oid = OrderUserSvc.GetById(userid); var tids = OrderSvc.GetByTids(oid); foreach (var item in tids) { if (lid == item) { return(3); } } return(0); }
/// <summary> /// 个人中心 /// </summary> /// <returns></returns> public ActionResult Center() { var user = UserSvc.GetById((long)UserHelper.GetUserId(HttpContext)); var ids = OrderUserSvc.GetById(user.Id).LastOrDefault(); var orders = OrderSvc.GetById(ids); UserOrderInfo info = new UserOrderInfo(); info.user = user; info.orders = orders; ViewBag.phonenum = user.PhoneNum; ViewBag.userid = UserHelper.GetUserId(HttpContext); ViewBag.IsGuide = new UserService().IsGuide((long)Session["LoginUserId"]); return(View(info)); }
/// <summary> /// 我的订单 /// </summary> /// <returns></returns> public ActionResult MyOrder(long userid) { var user = UserSvc.GetById((long)userid); var ids = OrderUserSvc.GetById(user.Id); var orders = OrderSvc.GetByIds(ids); MyOrderViewModel model = new MyOrderViewModel(); model.orders = orders; var guide = GuideSvc.GetByUid(userid); model.isguide = false; if (guide != null) { model.isguide = true; } ViewBag.phonenum = user.PhoneNum; return(View(model)); }
//Phương thức khởi tạo public OrderController() { _svc = new OrderSvc(); }
public ActionResult Btn_Yuyue(long?id) { long userid = (long)Session["LoginUserId"]; int ischeck = checkyuyue((long)id); if (ischeck == 1) { return(Json(new AjaxResult { status = "error", errorMsg = "无法预约自己" })); } if (ischeck == 2) { return(Json(new AjaxResult { status = "error", errorMsg = "导游未开启预约" })); } if (ischeck == 3) { return(Json(new AjaxResult { status = "error", errorMsg = "已经预约了" })); } if (ischeck == 4) { return(Json(new AjaxResult { status = "error", errorMsg = "导游不存在" })); } long oid = OrderSvc.CreateOrder((long)id); if (oid != null) { using (TransactionScope scope = new TransactionScope())//事物 { var issuccess = OrderUserSvc.appointment(userid, oid); if (issuccess) { bool isadd = LineSvc.AddNumOfPeople((long)id); if (!isadd) { return(Json(new AjaxResult { status = "error", data = "预约失败" })); } scope.Complete(); return(Json(new AjaxResult { status = "success", data = "预约成功" })); } else { return(Json(new AjaxResult { status = "error", errorMsg = "预约失败" })); } } } return(Json(new AjaxResult { status = "error", errorMsg = "" })); }