async Task ExecuteBookCommand(FieldDto fieldDto) { try { //IsBusy = true; var userId = Preferences.Get(AuthorizeConstants.UserIdKey, string.Empty); var storeId = Preferences.Get(AuthorizeConstants.StoreIdKey, string.Empty); var request = new ReservationRequest { StoreId = Convert.ToInt32(storeId), UserId = Convert.ToInt32(userId), FieldId = fieldDto.Id.Value, StartTime = new DateTime(SelectedDate.Year, SelectedDate.Month, SelectedDate.Day, FromTime.Hours, FromTime.Minutes, 0), StopTime = new DateTime(SelectedDate.Year, SelectedDate.Month, SelectedDate.Day, ToTime.Hours, ToTime.Minutes, 0), }; var start = request.StartTime.Value.ToString("MM/dd/yyyy h:mm tt"); var stop = request.StopTime.Value.ToString("MM/dd/yyyy h:mm tt"); bool answer = await Shell.Current.DisplayAlert("แจ้งเตือน!", $"\n ชื่อร้านที่จอง: {StoreName} \n ชื่อสนามที่จอง: {NameField} \n ราคา : {Price} \n ขนาดของสนาม : {SizeField} \n ตั้งแต่ : {start} \n " + $"ถึง : {stop}\n", "ใช่", "ไม่"); if (!answer) { return; } var result = await _reservationServices.CreateReservation(request); if (result) { await Shell.Current.DisplayAlert("แจ้งเตือน!", "ทำรายการจองเรียบร้อยแล้ว", "ตกลง"); await Shell.Current.Navigation.PopAsync(); } else { await Shell.Current.DisplayAlert("ไม่สามารถจองได้ในขณะนี้", "กรุณารลองใหม่ภายหลัง", "ตกลง"); } } catch (Exception ex) { throw ex; } finally { IsBusy = false; } }
public IActionResult Register(RegisterReservationViewModel registerReservation) { bool result = reservationServices.CreateReservation(registerReservation); if (!result) { return(View(registerReservation)); } else { return(Redirect("/")); } }