public ActionResult Book(BookingForm b) { Event e = _eventRequester.Get(b.EventId); bool enoughTickets = e.Tickets >= b.TicketsPurchased; try { if (ModelState.IsValid && enoughTickets) { G.Booking booking = new G.Booking() { UserId = b.UserId, EventId = b.EventId, PurchaseDate = DateTime.Now, TicketsPurchased = b.TicketsPurchased, TicketsPrice = b.TicketsPrice, Amount = b.TicketsPurchased * b.TicketsPrice }; return(RedirectToAction(nameof(Payment), new RouteValueDictionary(booking))); } ViewBag.Message = $"Only {e.Tickets} ticket(s) remaining"; return(View(b)); } catch { return(View("Error")); } }
/*Get reservation detail for mobile*/ public BookingForm GetBookingDetail(int id_reserve) { try { //find reservation var list = _dbContext.reservations.FirstOrDefault(x => x.Id_reserve == id_reserve); //if it is null if (list == null) { return(null); } int id_vacant = _dbContext.reservations.FirstOrDefault(x => x.Id_reserve == id_reserve).Id_vacancy; string mac_address = _dbContext.vacancies.FirstOrDefault(x => x.Id_vacancy == id_vacant).Mac_address; string location = _dbContext.lockerMetadatas.FirstOrDefault(x => x.Mac_address == mac_address).Location; string no_vacancy = _dbContext.vacancies.FirstOrDefault(x => x.Id_vacancy == list.Id_vacancy).No_vacancy; string size = _dbContext.vacancies.FirstOrDefault(x => x.Id_vacancy == id_vacant).Size; //create form in order to return to the user BookingForm result = new BookingForm() { UserID = list.Id_account, BookingID = list.Id_reserve, StartDate = list.StartDay, EndDate = list.EndDay, Location = location, Size = size, NumberVacancy = no_vacancy }; return(result); } catch (Exception) { //error return(null); } }
private void schedulerControl1_EditAppointmentFormShowing(object sender, DevExpress.XtraScheduler.AppointmentFormEventArgs e) { DevExpress.XtraScheduler.Appointment apt = e.Appointment; // Required to open the recurrence form via context menu. bool isNewAppointment = schedulerStorage1.Appointments.IsNewAppointment(apt); // Create a custom form. BookingForm myForm = new BookingForm((SchedulerControl)sender, apt, isNewAppointment); try { // Required for skins support. myForm.LookAndFeel.ParentLookAndFeel = schedulerControl1.LookAndFeel; //e.DialogResult = myForm.ShowDialog(); myForm.ShowDialog(); schedulerControl1.RefreshData(); e.Handled = true; } finally { myForm.Dispose(); MemoryHelper.ReduceMemory(); } }
public async Task<ActionResult> CreateBookingForRoom( Guid roomId, [FromBody] BookingForm bookingForm) { var room = await _roomService.GetRoomAsync(roomId); if (room == null) return NotFound(); var minimumStay = _dateLogicService.GetMinimumStay(); bool tooShort = (bookingForm.EndAt.Value - bookingForm.StartAt.Value) < minimumStay; if (tooShort) return BadRequest(new ApiError( $"The minimum booking duration is {minimumStay.TotalHours} hours.")); var conflictedSlots = await _openingService.GetConflictingSlots( roomId, bookingForm.StartAt.Value, bookingForm.EndAt.Value); if (conflictedSlots.Any()) return BadRequest(new ApiError( "This time conflicts with an existing booking.")); // Get the current user (TODO) var userId = Guid.NewGuid(); var bookingId = await _bookingService.CreateBookingAsync( userId, roomId, bookingForm.StartAt.Value, bookingForm.EndAt.Value); return Created( Url.Link(nameof(BookingsController.GetBookingById), new { bookingId }), null); }
/// <summary> /// @autor zp /// 获取已挂号数量 /// </summary> /// <param name="str">科室 医生 日期 挂号类别</param> /// <returns></returns> public int getHasCount(BookingForm form) { StringBuilder sql = new StringBuilder("select t.* from his.b_bookingform t where 1=1"); if (isNotBlank(form.registerDept)) { sql.Append(" and t.register_dept = '" + form.registerDept + "'"); } if (isNotBlank(form.doctor)) { sql.Append(" and t.doctor = '" + form.doctor + "'"); } if (isNotBlank(form.registerTime)) { sql.Append(" and t.register_time = '" + form.registerTime + "'"); } if (isNotBlank(form.registerType)) { sql.Append(" and t.register_type = '" + form.registerType + "'"); } List <BookingForm> list = OracleHelper.ExecuteToList <BookingForm>(sql.ToString()); int count = 0; if (list == null) { return(count); } else { return(list.Count); } }
public async Task <ActionResult> CreateBookingForRoom(Guid roomId, [FromBody] BookingForm bookingForm) //object je bindovany z body POST requestu, asp.net core robi model validaciu automaticky { var room = await _roomService.GetRoomAsync(roomId); if (room == null) { return(NotFound()); } var minimumStay = _dateLogicService.GetMinimumStay(); bool tooShort = (bookingForm.EndAt.Value - bookingForm.StartAt.Value) < minimumStay; if (tooShort) { return(BadRequest(new ApiError($"The minimum booking duration is {minimumStay.TotalHours} hours."))); } var conflictedSlots = await _openingService.GetConflictingSlots(roomId, bookingForm.StartAt.Value, bookingForm.EndAt.Value); if (conflictedSlots.Any()) { return(BadRequest(new ApiError("This time conflicts with an existing booking."))); } //TODO: Get the current user var userId = Guid.NewGuid(); var bookingId = await _bookingService.CreateBookingAsync(userId, roomId, bookingForm.StartAt.Value, bookingForm.EndAt.Value); return(Created(Url.Link(nameof(BookingsController.GetBookingById), new { bookingId }), null)); }
public ApiResult <List <BookingForm> > getBookingForm(BookingForm form, int currentPage, int pageSize) { apiResult.code = 200; apiResult.message = "查询成功"; apiResult.data = bookingFromDao.getBookingForms(form, currentPage, pageSize); apiResult.total = bookingFromDao.getBookingForms(form, 1, 1000000).Count; return(apiResult); }
public ApiResult <List <BookingForm> > getBookingForm([FromBody] JObject obj) { BookingForm form = obj["bookingForm"].ToObject <BookingForm>(); int currentPage = obj["currentPage"].ToObject <Int32>(); int pageSize = obj["pageSize"].ToObject <Int32>(); return(bookingFormService.getBookingForm(form, currentPage, pageSize)); }
public JsonResult BookingDetail(int id_reserve) { TimeZoneInfo zone = TimeZoneInfo.FindSystemTimeZoneById("SE Asia Standard Time"); DateTime dateTime = TimeZoneInfo.ConvertTime(DateTime.Now, zone); BookingForm result = _reserveRepo.GetBookingDetail(id_reserve); Log.Information("Booking detail from mobile {id}. {0}.", id_reserve, dateTime); return(Json(result)); }
public IActionResult FreeRooms() { var model = new BookingForm { StartDate = DateTime.UtcNow, EndDate = DateTime.UtcNow.AddDays(1) }; return(View(model)); }
public void Check_User_Input_Is_Valid_Int_Lower_Bounds() { // Arrange BookingForm form = new BookingForm(); // Act string textUserInput = "0"; int seatCount = 0; // Assert Assert.IsFalse(form.ValidateSeatCount(textUserInput, ref seatCount)); }
public int updBookingForm(BookingForm bookingForm) { string sql = "update his.b_bookingform set status = :status, updater = :updater where register_no = :register_no"; OracleParameter[] parameters = { new OracleParameter("status", bookingForm.status), new OracleParameter("register_no", bookingForm.registerNo), new OracleParameter("updater", bookingForm.updater) }; return(OracleHelper.ExecuteSql(sql, parameters)); }
public async Task <IActionResult> CreateBookingForRoomAsync( Guid roomId, [FromBody] BookingForm bookingForm, CancellationToken cancellationToken ) { if (!ModelState.IsValid) { return(BadRequest(new ApiError(ModelState))); } var room = await _roomService.GetRoomAsync(roomId, cancellationToken); if (room == null) { return(NotFound()); } var minimumStay = _dateLogicService.GetMinimumStay(); bool tooShort = (bookingForm.EndAt.Value - bookingForm.StartAt.Value) < minimumStay; if (tooShort) { return(BadRequest( new ApiError($"The minimum booking duration is {minimumStay.TotalHours}.") )); } var conflictedSlots = await _openingService.GetConflictingSlots( roomId, bookingForm.StartAt.Value, bookingForm.EndAt.Value, cancellationToken ); if (conflictedSlots.Any()) { return(BadRequest( new ApiError("This time conflicts with an existing booking.") )); } // Get the user ID (TODO) var userId = Guid.NewGuid(); var bookingId = await _bookingService.CreateBookingAsync( userId, roomId, bookingForm.StartAt.Value, bookingForm.EndAt.Value, cancellationToken ); return(Created( Url.Link(nameof(BookingsController.GetBookingByIdAsync), new { bookingId }), null )); }
public async Task <IActionResult> FreeRooms(BookingForm model) { var rooms = await this.user.AllFreeRooms(model.StartDate, model.EndDate); var newModel = new BookingForm { StartDate = model.StartDate, EndDate = model.EndDate, Rooms = rooms }; return(View(newModel)); }
/*Get all reservation each user that still active and not expire*/ public List <BookingForm> Pending(string id)//order by recent date { try { /*get all reservation each user that has status active is true*/ var intime = from list in _dbContext.reservations where list.Id_account == id && list.IsActive == true orderby list.StartDay select list; //if reservation is null if (intime == null) { return(null); } //create form to return to user List <BookingForm> result = new List <BookingForm>(); foreach (var run in intime) { string mac_address = _dbContext.vacancies.FirstOrDefault(x => x.Id_vacancy == run.Id_vacancy).Mac_address; string location = _dbContext.lockerMetadatas.FirstOrDefault(x => x.Mac_address == mac_address).Location; string no_vacancy = _dbContext.vacancies.FirstOrDefault(x => x.Id_vacancy == run.Id_vacancy).No_vacancy; string size = _dbContext.vacancies.FirstOrDefault(x => x.Id_vacancy == run.Id_vacancy).Size; BookingForm tmp = new BookingForm() { BookingID = run.Id_reserve, StartDate = run.StartDay, EndDate = run.EndDay, Location = location, Size = size, NumberVacancy = no_vacancy }; result.Add(tmp); } return(result.ToList()); } catch (Exception) { //error return(null); } }
public async Task <ActionResult> CreateBookingForRoom( Guid roomId, [FromBody] BookingForm form) { var userId = await _userService.GetUserIdAsync(User); if (userId == null) { return(Unauthorized()); } var room = await _roomService.GetRoomAsync(roomId); if (room == null) { return(NotFound()); } var minimumStay = _dateLogicService.GetMinimumStay(); bool tooShort = (form.EndAt.Value - form.StartAt.Value) < minimumStay; if (tooShort) { return(BadRequest(new ApiError( $"The minimum booking duration is {minimumStay.TotalHours} hours."))); } var conflictedSlots = await _openingService.GetConflictingSlots( roomId, form.StartAt.Value, form.EndAt.Value); if (conflictedSlots.Any()) { return(BadRequest(new ApiError( "This time conflicts with an existing booking."))); } var bookingId = await _bookingService.CreateBookingAsync( userId.Value, roomId, form.StartAt.Value, form.EndAt.Value); return(Created( Url.Link(nameof(BookingsController.GetBookingById), new { bookingId }), null)); }
public ApiResult <Int32> updBookingForm(BookingForm bookingForm) { ApiResult <Int32> apiResult = new ApiResult <Int32>(); int i = bookingFromDao.updBookingForm(bookingForm); if (i == 1) { apiResult.code = 200; apiResult.message = "修改成功"; apiResult.data = 1; } else { apiResult.code = 199; apiResult.message = "修改失败"; apiResult.data = 0; } return(apiResult); }
public async Task <IActionResult> UpdateAsync([FromBody] BookingForm bookingForm) { try { var modelresources = _mapper.Map <Booking>(bookingForm); _appDbContext.Bookings.Update(modelresources); _appDbContext.SaveChanges(); var res = await _appDbContext.Bookings .Select(BookingViewModel.SelectAllBooking) .ToListAsync(); return(Ok(res)); } catch (Exception ex) { return(BadRequest(ex)); } }
public int getCount(BookingForm form) { string sql = "select * from his.b_bookingform t where t.register_dept = :register_dept and t.doctor = :doctor and t.register_time like '%" + form.registerTime + "%'"; OracleParameter[] parameters = { new OracleParameter("register_dept", form.registerDept), new OracleParameter("doctor", form.doctor), }; OracleDataReader reader = OracleHelper.ExecuteReader(sql, parameters); List <BookingForm> list = new List <BookingForm>(); while (reader.Read()) { BookingForm bookingForm = new BookingForm(); bookingForm.registerNo = reader["register_no"].ToString(); list.Add(bookingForm); } return(list.Count); }
public int addBookingForm(BookingForm form) { string sql = "insert into his.b_bookingform(patient_no,register_time,register_fee,register_type,register_dept,waiting_no,creator,patient_name,doctor,address)" + "values(:patient_no,:register_time,:register_fee,:register_type,:register_dept,:waiting_no,:creator,:patient_name,:doctor,:address)"; OracleParameter[] parameters = { new OracleParameter("patient_no", form.patientNo), new OracleParameter("register_time", form.registerTime), new OracleParameter("register_fee", form.registerFee), new OracleParameter("register_type", form.registerType), new OracleParameter("register_dept", form.registerDept), new OracleParameter("waiting_no", form.waitingNo), new OracleParameter("creator", form.creator != null?form.creator:""), new OracleParameter("patient_name", form.patientName), new OracleParameter("doctor", form.doctor), new OracleParameter("address", form.address), }; List <BookingForm> list = new List <BookingForm>(); return(OracleHelper.ExecuteSql(sql, parameters)); }
public ApiResult <List <BookingForm> > addBookingForm(BookingForm bookingForm) { //Patient patient = new Patient(); //patient.patientNo = bookingForm.patientNo; //patient = patientDao.getAll(patient, 1, 1)[0]; //bookingForm.address = patient.address; //string time = bookingForm.registerTime; //bookingForm.registerTime = time.Substring(0, 10); //bookingForm.waitingNo = (bookingFromDao.getCount(bookingForm) + 1).ToString(); //bookingForm.registerTime = time; //根据科室名称 去查询科室位置 Department dept = new Department(); dept.deptName = bookingForm.registerDept; DepartmentDao deptDao = new DepartmentDao(); List <Department> deptList = deptDao.getDept(dept, 1, 100000); bookingForm.registerDept = dept.deptName; bookingForm.address = deptList[0].address; //计算当前是第几个挂号的 bookingForm.waitingNo = (bookingFromDao.getHasCount(bookingForm) + 1).ToString(); int i = bookingFromDao.addBookingForm(bookingForm); if (i == 1) { apiResult.code = 200; apiResult.message = "挂号成功"; apiResult.data = bookingFromDao.getBookingForms(bookingForm, 1, 10); } else { apiResult.code = 199; apiResult.message = "挂号失败"; apiResult.data = null; } return(apiResult); }
public async Task <IActionResult> PaymentForm() { var collection = Request.Form; BookingForm bookingForm = new BookingForm(); bookingForm.checkboxes = collection["checkedItems"]; bookingForm.Name = collection["firstName"]; bookingForm.CardNumber = collection["cardNumber"]; bookingForm.CardExpirationYear = Int16.Parse(collection["expYear"]); bookingForm.CardExpirationMonth = Int16.Parse(collection["expMonth"]); bookingForm.Cvs = collection["cvs"]; PaymentService.PaymentClient paymentClient = new PaymentService.PaymentClient(); Task <bool> isValid = paymentClient.ValidateCardAsync(new PaymentService.Card { CardExpirationMonth = bookingForm.CardExpirationMonth, CardExpirationYear = bookingForm.CardExpirationYear, CardNumber = bookingForm.CardNumber, Name = bookingForm.Name, Cvs = bookingForm.Cvs }); //tuto je vysledok z toho bool correctPayment = isValid.Result; foreach (String item in bookingForm.checkboxes) { _context.Seats.Where(S => S.XPosition == Int16.Parse("" + item[0]) && S.YPosition == Int16.Parse("" + item[2])).First().Payment = new Payment(); // seat.Payment = new Payment(); //_context.Seats.Update(seat); } _context.SaveChangesAsync(); bookingForm.PaymentCheck = correctPayment; //ServiceReference1.Service1Client paymentService = new ServiceReference1.Service1Client();*/ return(View(bookingForm)); }
/// <summary> /// 返回查询挂号余额的结果 拼接提示字符串 /// </summary> /// <param name="bookingForm"></param> /// <returns></returns> public ApiResult <int> queryBookFormCount(BookingForm bookingForm) { ApiResult <int> apiResult = new ApiResult <int>(); string dept = bookingForm.registerDept; string type = bookingForm.registerType; string date = bookingForm.registerTime; string doctor = bookingForm.doctor; int result = bookingFromDao.getHasCount(bookingForm); if (result < 20) { int count = 20 - result; apiResult.code = 200; apiResult.message = dept + ":‘" + date + "’的" + doctor + type + " 挂号剩余 " + count + " 个"; apiResult.data = result; } else { apiResult.code = 0; apiResult.message = dept + ":‘" + date + "’的" + doctor + type + " 挂号已满"; apiResult.data = result; } return(apiResult); }
public async Task <ActionResult> CreateBookingForRoom(Guid roomId, [FromBody] BookingForm bookingForm) { // Assume parameters have been validated (by framework) var room = await _roomService.GetRoomAsync(roomId); if (room == null) { return(NotFound()); } // Not less than the allowed time for the bookings. var minimumStay = _dateLogicService.GetMinimumStay(); bool tooShort = (bookingForm.EndAt.Value - bookingForm.StartAt.Value) < minimumStay; if (tooShort) { return(BadRequest(new ApiError($"Minimum booking duration is {minimumStay.TotalHours} hours"))); } // Need list of conflicting slots var conflictingSlots = await _openingService.GetConflictingSlots(roomId, bookingForm.StartAt.Value, bookingForm.EndAt.Value); if (conflictingSlots.Any()) { return(BadRequest(new ApiError("Time conflicts with an existing booking."))); } // TODO current user (authentication needed) // Need a user id, future problem to solve var userId = Guid.NewGuid(); var bookingId = await _bookingService.CreateBookingAsync(userId, roomId, bookingForm.StartAt.Value, bookingForm.EndAt.Value); // REturn result with a link that allows navigation to the new booking return(Created(Url.Link(nameof(BookingsController.GetBookingById), new { bookingId }), null)); }
private void bbiBookingControl_ItemClick(object sender, ItemClickEventArgs e) { BookingForm frm = new BookingForm(); frm.ShowDialog(); }
public ApiResult <Int32> updBookingForm([FromBody] BookingForm form) { return(bookingFormService.updBookingForm(form)); }
public ApiResult <int> queryHasCount([FromBody] JObject obj) { BookingForm form = obj["bookingForm"].ToObject <BookingForm>(); return(bookingFormService.queryBookFormCount(form)); }
public ApiResult <List <BookingForm> > addBookForm([FromBody] BookingForm form) { return(bookingFormService.addBookingForm(form)); }
public List <BookingForm> getBookingForms(BookingForm form, int currentPage, int pageSize) { string front = "select * from (select a.*,rownum rn from ("; string sql = "select t.register_no,t.patient_no,t.register_time,t.register_fee,t.register_type,t.register_dept,t.waiting_no,t.creator," + "t.updater,t.create_time,t.update_time,t.patient_name,t.doctor,t.address,t.status from his.b_bookingform t where 1=1 "; if (form != null) { if (isNotBlank(form.registerNo)) { sql = sql + " and t.register_no = '" + form.registerNo + "'"; } if (isNotBlank(form.registerTime)) { sql = sql + " and t.register_time = '" + form.registerTime + "'"; } if (isNotBlank(form.status)) { sql = sql + " and t.status = '" + form.status + "'"; } if (isNotBlank(form.doctor)) { sql = sql + " and t.doctor = '" + form.doctor + "'"; } if (isNotBlank(form.patientNo)) { sql = sql + " and t.patient_no = '" + form.patientNo + "'"; } if (isNotBlank(form.registerDept)) { sql = sql + " and t.register_dept = '" + form.registerDept + "'"; } if (isNotBlank(form.registerType)) { sql = sql + " and t.register_type = '" + form.registerType + "'"; } if (isNotBlank(form.waitingNo)) { sql = sql + " and t.waiting_no = '" + form.waitingNo + "'"; } } sql = sql + " order by register_no asc"; string back = ") a where rownum<=:max) where rn>=:min"; sql = front + sql + back; OracleParameter[] parameters = { new OracleParameter("min", pageSize * (currentPage - 1) + 1), new OracleParameter("max", pageSize * currentPage) }; OracleDataReader reader = OracleHelper.ExecuteReader(sql, parameters); List <BookingForm> list = new List <BookingForm>(); while (reader.Read()) { BookingForm bookingForm = new BookingForm(); bookingForm.registerNo = reader["register_no"].ToString(); bookingForm.patientNo = reader["patient_no"].ToString(); bookingForm.registerTime = reader["register_time"].ToString(); bookingForm.registerFee = reader["register_fee"].ToString(); bookingForm.registerType = reader["register_type"].ToString(); bookingForm.registerDept = reader["register_dept"].ToString(); bookingForm.waitingNo = reader["waiting_no"].ToString(); bookingForm.creator = reader["creator"].ToString(); bookingForm.createTime = reader["create_time"].ToString(); bookingForm.updater = reader["updater"].ToString(); bookingForm.updateTime = reader["update_time"].ToString(); bookingForm.patientName = reader["patient_name"].ToString(); bookingForm.doctor = reader["doctor"].ToString(); bookingForm.address = reader["address"].ToString(); bookingForm.status = reader["status"].ToString(); list.Add(bookingForm); } return(list); }