/// <summary> /// 预约记录数据页 /// </summary> /// <param name="search"></param> /// <returns></returns> public ActionResult ReservationList(SearchHelperModel search) { Expression <Func <Reservation, bool> > whereLambda = (m => DbFunctions.DiffDays(DateTime.Today, m.ReservationForDate) <= 7 && DbFunctions.DiffDays(DateTime.Today, m.ReservationForDate) >= 0); var rowsCount = 0; //补充查询条件 //根据预约日期查询 if (!String.IsNullOrEmpty(search.SearchItem0)) { whereLambda = (m => DbFunctions.DiffDays(DateTime.Parse(search.SearchItem0), m.ReservationForDate) == 0); } //根据预约人联系方式查询 if (!String.IsNullOrEmpty(search.SearchItem1)) { whereLambda = (m => m.ReservationPersonPhone.Contains(search.SearchItem1)); } //load data var list = new BLLReservation().GetReservationList(search.PageIndex, search.PageSize, out rowsCount, whereLambda, m => m.ReservationForDate, m => m.ReservationTime, false, false); var dataList = list.ToPagedList(search.PageIndex, search.PageSize, rowsCount); return(View(dataList)); }
public ActionResult Check(Guid id) { var r = new BLLReservation().Fetch(re => re.ReservationId == id); return(View(r)); }
public ActionResult MakeReservation(ReservationViewModel model) { var result = new JsonResultModel { Data = false, Status = JsonResultStatus.RequestError }; try { if (ModelState.IsValid) { string msg; if (!ReservationHelper.IsReservationAvailabel(model, out msg)) { result.Msg = msg; return(Json(result)); } var reservation = new Reservation() { ReservationForDate = model.ReservationForDate, ReservationForTime = model.ReservationForTime, ReservationPlaceId = model.ReservationPlaceId, ReservationUnit = model.ReservationUnit, ReservationActivityContent = model.ReservationActivityContent, ReservationPersonName = model.ReservationPersonName, ReservationPersonPhone = model.ReservationPersonPhone, ReservationFromIp = HttpContext.Request.UserHostAddress, //记录预约人IP地址 UpdateBy = model.ReservationPersonName, UpdateTime = DateTime.Now, ReservationId = Guid.NewGuid() }; //TODO:验证最大可预约时间段,同一个手机号,同一个IP地址 foreach (var item in model.ReservationForTimeIds.Split(',').Select(_ => Convert.ToInt32(_))) { reservation.ReservationPeriod += (1 << item); } var bValue = new BLLReservation().Add(reservation); if (bValue > 0) { result.Data = true; result.Msg = "预约成功"; result.Status = JsonResultStatus.Success; } else { result.Msg = "预约失败"; result.Status = JsonResultStatus.ProcessFail; } return(Json(result)); } } catch (Exception ex) { Logger.Error(ex); result.Status = JsonResultStatus.ProcessFail; result.Msg = ex.Message; } return(Json(result)); }