public static async Task <BookingResult> Book(string userId, ReservationForm reservationForm) { HttpClient httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Add("UserID", userId); try { var response = await httpClient.PostAsJsonAsync($"{GetCampingAPIUrl()}/camping/book", GetReservationObj(reservationForm)); var resultString = await response.Content.ReadAsStringAsync(); var bookingResult = JsonConvert.DeserializeObject <BookingResult>(resultString); return(bookingResult); } catch (Exception ex) { return(new BookingResult() { Errors = new List <string>() { "Ocorreu um problema ao efetuar sua reserva. Por favor, tente novamente." } }); } }
public void submitReservationRequest(Account acct) { this.acct = acct; ReservationForm form = new ReservationForm(this); form.ShowDialog(); }
private void randevuEkranıToolStripMenuItem_Click(object sender, EventArgs e) { ReservationForm ChildForm = new ReservationForm(); ChildForm.MdiParent = this; ChildForm.Show(); }
public IActionResult Edit(int?id, ReservationForm record) //using a nullable integer id and the Product object as parameters { var reservationForm = _context.Reservations.Where(r => r.ReservationID == id).SingleOrDefault(); { reservationForm.PetName = record.PetName; reservationForm.Animal = record.Animal; reservationForm.Medications = record.Medications; reservationForm.MedicationID = record.MedicationID; reservationForm.DatePicker = record.DatePicker; reservationForm.Name = record.Name; reservationForm.Email = record.Email; reservationForm.Phone = record.Phone; reservationForm.Address = record.Address; reservationForm.Type = record.Type; reservationForm.CustomerType = record.CustomerType; reservationForm.Concerns = record.Concerns; reservationForm.DateModified = DateTime.Now; } _context.Reservations.Update(reservationForm); //update the existing values _context.SaveChanges(); //save the record from the database return(RedirectToAction("Index")); }
public static void AddFastFlightReservation(ReservationForm form) { using (var _context = new DiemServiceDB()) { string caller = ((ClaimsPrincipal)HttpContext.Current.User).FindFirst("username").Value; User found = _context.UserDbSet.Where(u => u.Username == caller).FirstOrDefault(); if (found.Role != Role.RegisteredUser || found == null || form.FlightId == 0 /*|| form.Seat == 0*/ || form.Passport == 0) { throw new Exception("BAD QUERY"); } Flight wanted = _context.FlightDbSet.Where(u => u.Id == form.FlightId).FirstOrDefault(); StringBuilder sb = new StringBuilder(wanted.Seats); if (sb[form.Seat] != '5') { throw new Exception("NOT AN OFFER"); } sb[form.Seat] = '1'; wanted.Seats = sb.ToString(); FlightReservation fr = _context.FlightReservationDbSet.Add(new FlightReservation(found.Name, found.LastName, form.Seat, form.Passport, found, wanted)); _context.RegisteredUserDbSet.Where(u => u.Id == found.UlogaID).First().FlightReservations.Add(fr); MailServiceManager.SendReservationEmail(fr); wanted.Reservations.Add(fr); _context.SaveChanges(); } }
private void addReservationToolStripMenuItem_Click(object sender, EventArgs e) { ReservationForm reservForm = new ReservationForm(); reservForm.MdiParent = this; reservForm.Show(); }
public ActionResult ReservCreate(ReservationForm reservationFormSingle) { db.ReservationForm.Add(reservationFormSingle); db.SaveChanges(); ModelState.Clear(); return(RedirectToAction("Reservation")); }
private async Task AfterReservationConfirmationAsync(IDialogContext context, IAwaitable <bool> result) { try { var confirm = await result; if (confirm) { ReservationForm reservationForm = context.UserData.GetValue <ReservationForm>("reservationForm"); var bookingResult = await CampingService.Book(context.Activity.From.Id, reservationForm); if (bookingResult.Errors != null && bookingResult.Errors.Count > 0) { await context.PostAsync("Houve um erro ao emitir sua reserva. Por favor, tente novamente."); } else { await context.PostAsync($"Sua reserva foi confirmada com o ID {bookingResult.Id}."); } } else { await context.PostAsync("Ok, posso te ajudar em mais alguma coisa?"); } } finally { context.UserData.RemoveValue("reservationForm"); } context.Wait(MessageReceived); }
public List <ReservationForm> CreateReservationForm(ReservationForm reservationForm) { using TinyCollegeContext _context = new TinyCollegeContext(_builder.Options); _context.Add(reservationForm); _context.SaveChanges(); return(_context.ReservationForms.Where(x => x.ReservationFormId == _context.ReservationForms.Max(x => x.ReservationFormId)).ToList()); }
void label5_Click(object sender, EventArgs e) { Form form = new ReservationForm(); form.Show(); this.Hide(); t.Stop(); form.FormClosed += form_FormClosed; }
//void FilmsForm_Deactivate(object sender, EventArgs e) //{ // ((Form)(sender)).Close(); //} void label6_Click(object sender, EventArgs e) { //this.Close(); Form reservationForm = new ReservationForm(); reservationForm.Show(); this.Hide(); reservationForm.FormClosed += reservationForm_FormClosed; }
public List <ReservationForm> EditReservationForm(ReservationForm reservationForm) { using TinyCollegeContext _context = new TinyCollegeContext(_builder.Options); var tmpReservationForm = _context.ReservationForms.First(x => x.ReservationFormId == reservationForm.ReservationFormId); _context.Entry(tmpReservationForm).CurrentValues.SetValues(reservationForm); _context.SaveChanges(); return(_context.ReservationForms.Where(x => x.ReservationFormId == reservationForm.ReservationFormId).ToList()); }
public static async Task <decimal?> GetPrice(ReservationForm reservationForm) { HttpClient httpClient = new HttpClient(); var result = await httpClient.PostAsJsonAsync($"{GetCampingAPIUrl()}/camping/pricing", GetReservationObj(reservationForm)); var jsonResult = await result.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <decimal?>(jsonResult)); }
private static object GetReservationObj(ReservationForm reservationForm) { return(new { reservationForm.MainPaxName, reservationForm.NumberOfGuests, reservationForm.ArrivalDate, reservationForm.DepartureDate, reservationForm.IncludeTent }); }
public async Task <ActionResult <Reservation> > PostReservation(ReservationForm reservation) { var result = await _reservationsService.PostReservation(reservation); if (result) { return(Ok()); } return(Problem()); }
/*find available vacancy during the day reservation*/ public List <Vacancy> CheckAvailableDay(ReservationForm reserve) { var overlap = from reservelist in _dbContext.reservations where reservelist.StartDay <= reserve.StartDay && reservelist.EndDay >= reserve.StartDay && (reservelist.Status == Status.Use || reservelist.Status == Status.Unuse) select reservelist; var availableVacant = from vacantlist in _dbContext.vacancies join lockerlist in _dbContext.lockerMetadatas on vacantlist.Mac_address equals lockerlist.Mac_address where !(overlap.Any(x => x.Id_vacancy == vacantlist.Id_vacancy)) && lockerlist.Location == reserve.Location select vacantlist; return(availableVacant.ToList()); }
public IActionResult Index() { var model = new ReservationForm { Restaurants = JsonConvert.SerializeObject(_service.GetRestaurants(), _jsonSettings), Tables = JsonConvert.SerializeObject(_service.GetTables(), _jsonSettings), AreBigTablesAvailable = JsonConvert.SerializeObject(true), ProviderCode = "NElements" }; return(View(model)); }
public async Task Reserver(IDialogContext context, WitResult result) { var form = ReservationForm.ReadFromWit(result); if (string.IsNullOrWhiteSpace(form.RestaurantName) || !form.PeopleCount.HasValue || !form.ReservationDate.HasValue) { await context.PostAsync("Des informations sont manquantes"); return; } await context.PostAsync($"Je vous ai réservé une table pour {form.PeopleCount.Value} chez {form.RestaurantName} à {form.ReservationDate.Value.ToString("HH\\hmm")} le {form.ReservationDate.Value.ToString("dd/MM/yyyy")}"); }
public async Task Reserver(IDialogContext context, WitResult result) { var form = ReservationForm.ReadFromWit(result); if (string.IsNullOrWhiteSpace(form.RestaurantName) || form.PeopleCount == 0 || form.ReservationDate == null) { var reservationForm = new FormDialog <ReservationForm>(form, ReservationForm.BuildForm, FormOptions.PromptInStart); context.Call(reservationForm, ResumeAfterReservationFormCompleted); return; } await ResumeReservation(context, form); }
public IEnumerable <Car> GetAvailableCars(ReservationForm reservationForm) { var reservationStartDate = reservationForm.ReceptionDate; var reservationEndDate = reservationForm.ReturnDate; var reservationsIds = _reservationRepository.Reservations .Where(x => x.StartDate >= reservationStartDate && x.EndTime <= reservationEndDate || x.StartDate >= reservationStartDate && x.EndTime >= reservationEndDate || x.StartDate <= reservationStartDate && x.EndTime <= reservationEndDate) .Select(x => x.CarId); return(!reservationsIds.Any() ? _carRepository.Cars : _carRepository.Cars.Where(x => !reservationsIds.Contains(x.CarId))); }
public IActionResult Reservation(ReservationForm reservationForm) { if (!ModelState.IsValid) { return(View("Index", reservationForm)); } ViewData["availableCars"] = _reservationHelper.GetAvailableCars(reservationForm); var model = new AvailableCarsForm { ReservationForm = reservationForm }; return(View("AvailableCars", model)); }
public IActionResult AddReservation([FromBody] ReservationForm reserve) { TimeZoneInfo zone = TimeZoneInfo.FindSystemTimeZoneById("SE Asia Standard Time"); DateTime dateTime = TimeZoneInfo.ConvertTime(DateTime.Now, zone); int result = _reserveRepo.AddReservation(reserve); if (result == 0) { Log.Information("Add reservation Error. {DateTime}, {1}.", reserve.Id_account, dateTime); return(NotFound("Error")); } else { Log.Information("Add reservation {accountID} done. {DateTime}.", reserve.Id_account); return(Ok(result)); } }
public List <ReservationForm> DeleteReservationForm(ReservationForm reservationForm) { using TinyCollegeContext _context = new TinyCollegeContext(_builder.Options); try { _context.ReservationForms.Attach(reservationForm); _context.ReservationForms.Remove(reservationForm); _context.SaveChanges(); } catch (Exception e) { // ignored } return(_context.ReservationForms.ToList()); }
public IActionResult Insert([FromBody] ReservationForm r) { if (ModelState.IsValid) { try { return(Ok(_reservationService.Insert(new ReservationCustomer(r.ResDate, r.StartHour, r.EndHour, r.NumPlaceAvailable, r.UserId)))); } catch (Exception e) { return(BadRequest(e.Message)); } } return(BadRequest()); }
public StartVindow() { InitializeComponent(); this.rf = new ReservationForm(); this.listData = new List <string>(); this.numberFieldsSelected = 0; this.numberDishesSelected = 0; cbTypeRice.Items.Add("Ninguna"); cbTypeRice.Items.Add("Arroz Blanco"); cbTypeRice.Items.Add("Arroz Integral"); cbTypeRice.Items.Add("Arroz Mixto"); cbTypeRice.Items.Add("Arroz con Pollo"); cbProtein.Items.Add("Ninguna"); cbProtein.Items.Add("Fillete de Res"); cbProtein.Items.Add("Fillete de Pollo"); cbProtein.Items.Add("Fillete de Pescado"); cbProtein.Items.Add("Muchacho"); cbProtein.Items.Add("Milanesa de Pollo"); cbProtein.Items.Add("Pescado Frito"); cbStarterPlate.Items.Add("Ninguna"); cbStarterPlate.Items.Add("Pasta"); cbStarterPlate.Items.Add("Frijoles"); cbStarterPlate.Items.Add("Lentejas"); cbStarterPlate.Items.Add("Garbanzos"); cbStarterPlate.Items.Add("Blanquillo"); cbSalad.Items.Add("Ninguna"); cbSalad.Items.Add("Ensalada Verde"); cbSalad.Items.Add("Ensalada Roja"); cbSalad.Items.Add("Ensalada Dulce"); cbSoup.Items.Add("Ninguna"); cbSoup.Items.Add("Sancocho"); cbSoup.Items.Add("Ajiaco"); cbSoup.Items.Add("Trifasico"); cbDrink.Items.Add("Ninguna"); cbDrink.Items.Add("Limonada"); cbDrink.Items.Add("Jugo de Mora"); cbDrink.Items.Add("Jugo de lulo"); }
public async Task <bool> PostReservation(ReservationForm reservation) { try { int contactID = 0; // check if the user exists, if not, create a new user with the provided data. if (ContactExists(Convert.ToInt32(reservation.ContactID))) { contactID = Convert.ToInt32(reservation.ContactID); } else { Contact contact = new Contact() { ContactName = reservation.ContactName, BirthDate = Convert.ToDateTime(reservation.BirthDate), ContactTypeId = Convert.ToInt32(reservation.ContactType), PhoneNumber = reservation.Phone, }; // save the contact to get the id and relate the new reservation _context.Contacts.Add(contact); _context.SaveChanges(); contactID = contact.Id; } // create the reservation _context.Reservations.Add(new Reservation() { ContactId = contactID, Description = reservation.editorContent }); await _context.SaveChangesAsync(); return(true); } catch (Exception ex) { return(false); } }
public static void InviteUser(ReservationForm form) { using (var _context = new DiemServiceDB()) { string caller = ((ClaimsPrincipal)HttpContext.Current.User).FindFirst("username").Value; User instigator = _context.UserDbSet.Where(u => u.Username == caller).FirstOrDefault(); User invited = _context.UserDbSet.Where(u => u.Username == form.InvitedUsername).FirstOrDefault(); Flight wanted = _context.FlightDbSet.Where(u => u.Id == form.FlightId).FirstOrDefault(); if (invited.Role != Role.RegisteredUser || invited == null) { return; } FlightReservation fr = _context.FlightReservationDbSet.Add(new FlightReservation(invited.Name, invited.LastName, form.Seat, invited, wanted) { Invited_By = instigator }); _context.RegisteredUserDbSet.Where(u => u.Id == invited.UlogaID).First().FlightReservations.Add(fr); MailServiceManager.SendInvitationEmail(fr); _context.SaveChanges(); } }
public static void AddRandomFlightReservation(ReservationForm form) { using (var _context = new DiemServiceDB()) { if (form == null || String.IsNullOrEmpty(form.Name) || String.IsNullOrEmpty(form.LastName) || form.Passport == 0 || form.Seat == 0) { throw new Exception("BAD"); } Flight wanted = _context.FlightDbSet.Where(u => u.Id == form.FlightId).FirstOrDefault(); StringBuilder sb = new StringBuilder(wanted.Seats); if (sb[form.Seat] == '1') { throw new Exception("ALREADY TAKEN"); } sb[form.Seat] = '1'; wanted.Seats = sb.ToString(); FlightReservation fr = _context.FlightReservationDbSet.Add(new FlightReservation(form.Name, form.LastName, form.Seat, form.Passport, wanted)); wanted.Reservations.Add(fr); _context.SaveChanges(); } }
public IActionResult NewReservation(ReservationForm model, string returnUrl = null) { ShowLoggedUser(); ViewData["Materials"] = MaterialLogic.MaterialNames(); if (ModelState.IsValid) { model.AvaibleDateTime = ReservationLogic.IsDateTimeAvaible(model.RequstedDate); if (model.RequstedDate < DateTime.Now) { model.AvaibleDateTime = false; } if (model.AvaibleDateTime) { try { ReservationLogic.CreateReservation( _userSession.GetLoggedUser(HttpContext).User.Id, model.RequstedDate, model.Material, model.MaterialAmount); return(RedirectToAction("ReservationList")); } catch (DatabaseException e) { return(View("Error", new ErrorViewModel() { RequestId = e.Message })); } } } return(View(model)); }
private async Task ResumeReservation(IDialogContext context, ReservationForm reservation) { await context.PostAsync($"Je vous ai réservé une table pour {reservation.PeopleCount} chez {reservation.RestaurantName} à {reservation.ReservationDate.DateTime.ToString("HH\\hmm")} le {reservation.ReservationDate.DateTime.ToString("dd/MM/yyyy")}"); }