public string GetContainerStatus(smART.Model.Scale modelEntity, smART.Model.Container container, smART.Model.smARTDBContext dbContext) { string status = string.Empty; try { Model.Booking modBooking = container.Booking; smART.Model.DispatcherRequest modDispatcher = dbContext.T_Dispatcher.FirstOrDefault(m => m.Booking_Ref_No.ID == container.Booking.ID); if (modBooking != null && modBooking.Invoice_Generated_Flag == true) { status = "Closed"; } else if (modelEntity != null && modelEntity.Ticket_Status.ToLower() == "open") { status = "WIP"; } else if (modelEntity != null && modelEntity.Ticket_Status.ToLower() == "close") { if (modDispatcher != null && modDispatcher.RequestType.ToLower() == "drop off only") { status = "Shipped"; } else if (container.Status.ToLower() == "wip" || container.Status.ToLower() == "open-empty") { status = "Open-Loaded"; } else { status = container.Status; } } else if (modDispatcher != null && modDispatcher.RequestType.ToLower() == "pickup only") { status = "Open-Empty"; } else if (modDispatcher != null && modDispatcher.RequestType.ToLower() == "drop off only") { if (modelEntity != null) { status = "Shipped"; } else { status = "Open-Empty"; } } } catch (Exception ex) { bool rethrow; rethrow = BusinessRuleExceptionHandler.HandleException(ref ex, modelEntity.Updated_By, modelEntity.GetType().Name, modelEntity.ID.ToString()); if (rethrow) { throw ex; } } return(status); }
public async Task <IActionResult> PostBooking([FromBody] BookingDto model, [FromHeader(Name = "x-requestid")] Guid requestId) { var booking = new Model.Booking(); //** Charge Payment //** Map DTO's to models and add to repo... var paymentMethod = _mapper.Map <Model.PaymentMethod>(model); _repo.Insert(paymentMethod); booking = _mapper.Map <Model.Booking>(model); var bookingPayment = _mapper.Map <Model.BookingPayment>(model); booking.BookingPayments.Add(bookingPayment); _repo.Insert(booking); await _repo.SaveAll(); /* * //** Send email of booking * var _emailText = await _razorViewToStringRenderer.RenderViewToStringAsync("~/Views/Email/BookingConfirmation.cshtml", booking); * * Booking.API.Model.EmailModel ObjEmail = new Booking.API.Model.EmailModel(); * ObjEmail.Email = _emailText; * ObjEmail.To.Name = booking.CustomerName; * ObjEmail.To.Email = "*****@*****.**"; * ObjEmail.Subject = "Booking Confirmation #: " + booking.Id; * * await _emailNotifier.SendEmailAsync(ObjEmail); */ return(NoContent()); }
private void DeleteClient_Click(object sender, EventArgs e) { try { Model.Client client = new Model.Client(); client = (Model.Client)Clients.SelectedItem; IEnumerable <Model.Booking> bok = Manipulation.db.Bookings.ToList <Model.Booking>(); Model.Booking one = bok .Where(b => b.Client_code == client.Client_code) .FirstOrDefault(); if (one != null) { throw new Exception("Сначала удалите все брони клиента, затем самого клиента!"); } foreach (Model.Pay p in client.Pays.ToList <Model.Pay>()) { Manipulation.Delete <Model.Pay>(p); } Manipulation.Delete <Model.Client>(client); UpdateDataGrid(); MessageBox.Show("Запись удалена!"); } catch (NullReferenceException ex) { MessageBox.Show("Выберите клиента, чтобы удалить его!"); } catch (ArgumentNullException ex) { MessageBox.Show("Выберите клиента, чтобы удалить его!"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//Get Hotel list public List <Model.Hotel> GetAllHotel() { var entities = _dbContext.Hotels.ToList(); List <Model.Hotel> list = new List <Model.Hotel>(); if (entities != null) { foreach (var item in entities) { Model.Hotel hotel = new Model.Hotel(); hotel.Id = item.Id; hotel.Name = item.Name; hotel.Address = item.Address; hotel.City = item.City; hotel.Pincode = item.Pincode; hotel.ContactNumber = item.ContactNumber; hotel.ContactPerson = item.ContactPerson; hotel.IsActive = item.IsActive; hotel.CreatedDate = item.CreatedDate; hotel.CreatedBy = item.CreatedBy; hotel.Rooms = new List <Model.Room>(); foreach (var room in item.Rooms) { Model.Room hotelroom = new Model.Room(); hotelroom.Id = room.Id; hotelroom.HotelId = room.HotelId; hotelroom.Name = room.Name; hotelroom.Price = room.Price; hotelroom.IsActive = room.IsActive; hotelroom.CreatedBy = room.CreatedBy; hotelroom.CreatedDate = room.CreatedDate; hotelroom.CategoryId = room.CategoryId; hotelroom.Bookings = new List <Model.Booking>(); foreach (var booking in room.Bookings) { Model.Booking hotelroombooking = new Model.Booking(); hotelroombooking.Id = booking.Id; hotelroombooking.RoomId = booking.RoomId; hotelroombooking.Id = booking.Id; hotelroombooking.BookingDate = booking.BookingDate; hotelroombooking.BookingStatusId = booking.BookingStatusId; hotelroom.Bookings.Add(hotelroombooking); } hotel.Rooms.Add(hotelroom); } list.Add(hotel); } } List <Model.Hotel> SortedList = list.OrderBy(o => o.Name).ToList(); return(SortedList); }
private void Book_Click(object sender, RoutedEventArgs e) { try { Button button = (Button)sender; string number = (string)button.Tag; Random rand = new Random(); int discount = GetDiscount(); Model.Pay pay = new Model.Pay(); Model.Room room = new Model.Room(); room = Manipulation.db.Rooms.Find(number); room.Booking = "Да"; Model.Booking booking = new Model.Booking { Booking_number = Randomizer(rand, 1000, 100000), Client_code = client1.Client_code, Client = client1, Arrivall = DateTime.Parse(arrival.Text), DateOfBooking = DateTime.Today, Departuree = DateTime.Parse(departure.Text), TypeOfFood = (string)TypeOfFood.SelectedItem, TypeOfFood1 = Manipulation.db.TypeOfFoods.Find((string)TypeOfFood.SelectedItem), Payment_number = Randomizer(rand, 1000, 100000), Room = room, Room_code = room.Room_code }; booking.Pay = new Model.Pay() { Payment_number = booking.Payment_number, DateOfPay = DateTime.Today, Client = client1, Payer = client1.Client_code, Card_number = Randomizer(rand, 10000, 100000).ToString(), Summ = booking.TypeOfFood1.Summa + room.CategoryOfRoom.Cost * Nights - discount * 10 / 100 }; Manipulation.db.Bookings.Add(booking); MessageBox.Show(String.Concat("Вы зарегестрировали бронь!\n", "Ваша скидка - ", discount, " %"), "Поздравляем!"); Manipulation.db.SaveChanges(); ClearItems(); } catch (NullReferenceException ex) { MessageBox.Show("Заполните все данные!"); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { MessageBox.Show("Заполните все данные!"); } catch (Exception exp) { MessageBox.Show(exp.Message, "Упс.."); } }
private void DeleteBooking_Click(object sender, EventArgs e) { try { Model.Booking book = new Model.Booking(); Model.SelectBooking booking = (Model.SelectBooking)Booking.SelectedItem; book = Manipulation.db.Bookings.Find(booking.Booking_number); book.Room.Booking = "Нет"; Manipulation.Delete <Model.Booking>(book); UpdateDataGrid(); MessageBox.Show("Запись удалена!"); } catch (NullReferenceException ex) { MessageBox.Show("Выберите бронь, чтобы удалить ее!"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void UpdateContainer(smART.ViewModel.DispatcherRequest businessEntity, smART.Model.DispatcherRequest modelEntity, smART.Model.smARTDBContext dbContext) { try { if (modelEntity.RequestCategory.ToLower() == "container" && !string.IsNullOrEmpty(businessEntity.Container_No)) { Model.Booking modBooking = dbContext.T_Booking_Ref.FirstOrDefault(o => o.ID.Equals(modelEntity.Booking_Ref_No.ID)); if (modBooking != null) { Model.Container modContainer = dbContext.T_Container_Ref.Include("Booking").FirstOrDefault(o => o.Container_No == businessEntity.Container_No && o.Active_Ind == true); if (modContainer == null) { smART.Model.Container modNewcontainer = new smART.Model.Container(); modNewcontainer.Booking = modBooking; modNewcontainer.Container_No = businessEntity.Container_No; modNewcontainer.Created_Date = modelEntity.Time; modNewcontainer.Last_Updated_Date = modelEntity.Time; modNewcontainer.Created_By = modelEntity.Created_By; modNewcontainer.Updated_By = modelEntity.Updated_By; modNewcontainer.Date_In = DateTime.Now; modNewcontainer.Status = GetContainerStatus(modBooking, modelEntity, dbContext); modNewcontainer.Active_Ind = true; Model.Container insertedObject = dbContext.T_Container_Ref.Add(modNewcontainer); modContainer = insertedObject; dbContext.SaveChanges(); modelEntity.Container = modContainer; } else { modContainer.Last_Updated_Date = DateTime.Now; modContainer.Updated_By = modelEntity.Updated_By; modelEntity.Container = modContainer; modelEntity.Booking_Ref_No = dbContext.T_Booking_Ref.FirstOrDefault(o => o.ID == modContainer.Booking.ID); modContainer.Status = GetContainerStatus(modelEntity.Booking_Ref_No, modelEntity, dbContext); dbContext.SaveChanges(); } } } } catch (Exception ex) { bool rethrow; rethrow = BusinessRuleExceptionHandler.HandleException(ref ex, businessEntity.Updated_By, businessEntity.GetType().Name, businessEntity.ID.ToString()); if (rethrow) { throw ex; } } }
//Infogar ny bokning public void BookingListView_InsertItem(Model.Booking booking) { if (ModelState.IsValid) { try { Service.SaveBooking(booking); //statusmeddelande UploadLabel.Visible = true; UploadLabel.Text = "Ny bokning lades till."; } catch (Exception) { ModelState.AddModelError(String.Empty, "Fel uppstod då bokning skulle läggas till i listan"); } } }
protected void booking_Command(object sender, CommandEventArgs e) { //sparar bokningsid för vald post int bookingID = int.Parse((string)e.CommandArgument); Session["BookingId"] = ((int?)Session["BookingId"] ?? 0); Session["BookingId"] = bookingID; //visar kundbokning & tar bort listor CustomerFormView.Visible = true; Unbooked1ListView.Visible = false; Unbooked2ListView.Visible = false; //Information att använda i bokningsinfo Model.Booking bookingObject = new Model.Booking(); bookingObject = Service.GetBooking(bookingID); //Bokningsinfo Literal2.Visible = true; Literal2.Text = String.Format(Literal2.Text = "Bokning avseende vecka {0} år {1}. Pris {2}:-.", bookingObject.Week, bookingObject.Year, bookingObject.Price); }
public async Task <IActionResult> PutBooking([FromBody] Model.Booking model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var booking = await _repo.Get(model.Id); if (booking == null) { return(NotFound($"Booking with id {model.Id} not found.")); } _repo.Update(model); await _repo.SaveAll(); return(Ok()); }
public async Task TryBookTimeslot(Model.Timeslot timeslot, Model.Booking booking) { if (timeslot.StartDateTime < DateTime.Now) { throw new Exception("Cannot book old date"); } var studentId = await state.GetPersonIdAsync(); booking.StudentId = studentId; var student = await studentQuery.GetStudentWithFutureBookings(studentId); student.AddBooking(booking); await bookingCommand.Create(booking); var slot = await timeslotQuery.GetSingle(timeslot.Id); slot.BookingId = booking.Id; slot.Booking = booking; await timeslotCommand.UpdateWithConcurrencyCheck(slot); }
public static void Initialise(DatabaseContext context) { context.Database.EnsureCreated(); if (!context.Booking.Any()) { Model.Booking[] seats = new Model.Booking[100]; char[] characters = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J' }; for (short i = 0; i < 100; i++) { seats[i] = new Model.Booking { SeatId = (characters[i / 10] + ((i % 10) + 1).ToString()).ToString() }; } foreach (var seat in seats) { context.Booking.Add(seat); } context.SaveChanges(); } }
private void UpdateCustomerDetails(int customerId, string customerName, string customerPhone, Model.Booking booking) { _logger.LogInformation("----- CustomerDetailsChangedIntegrationEventHandler - Updating customer infromation...."); if (!string.IsNullOrWhiteSpace(customerName)) { booking.CustomerName = customerName; } if (!string.IsNullOrWhiteSpace(customerPhone)) { booking.CustomerPhone = customerPhone; } _repository.Update(booking); }
public void Add_Click(object sender, EventArgs e) { try { Model.Client client = new Model.Client(); Model.Pay pay = new Model.Pay(); Model.Room room = new Model.Room(); Model.TypeOfFood type = new Model.TypeOfFood(); Model.Booking booking = new Model.Booking(); string numberOfRoom = (string)Room_Code.SelectedItem; string[] split = numberOfRoom.Split(' '); Random rand = new Random(); room = Manipulation.db.Rooms.Find(split[0]); type = Manipulation.db.TypeOfFoods.Find((string)Type_food.SelectedItem); if (ClientExist.IsChecked == true) { BindingExpression b = card_number.GetBindingExpression(TextBoxWatermarked.TextProperty); if (b.HasValidationError) { throw new Exception("Исправьте неправильно введенные данные!"); } IEnumerable <Model.Client> cli = Manipulation.db.Clients.Where(w => w.Full_name == (string)ListOfClients.SelectedItem); client = cli.First(); } else { BindingExpression b = card_number.GetBindingExpression(TextBoxWatermarked.TextProperty); BindingExpression f = Full_Name.GetBindingExpression(TextBoxWatermarked.TextProperty); BindingExpression p = Email.GetBindingExpression(TextBoxWatermarked.TextProperty); BindingExpression s = Phone.GetBindingExpression(TextBoxWatermarked.TextProperty); BindingExpression a = PassNumber.GetBindingExpression(TextBoxWatermarked.TextProperty); if (b.HasValidationError || p.HasValidationError || s.HasValidationError || f.HasValidationError || a.HasValidationError) { throw new Exception("Исправьте неправильно введенные данные!"); } int code_client = Randomizer(rand, 1000, 100000); client.Client_code = code_client; client.Full_name = Full_Name.Text; client.Phone = Phone.Text; client.Email = Email.Text; client.Passport_number = PassNumber.Text; client.Birthdate = DateTime.Parse(DateBornC.Text); Manipulation.db.Clients.Add(client); } pay.Payment_number = Randomizer(rand, 10, 500); pay.Card_number = card_number.Text; pay.Summ = type.Summa + room.CategoryOfRoom.Cost * Nights; pay.Payer = client.Client_code; pay.DateOfPay = DateTime.Parse(dateOfPay.Text); client.Pays.Add(pay); Manipulation.db.Pays.Add(pay); room.Booking = "Да"; booking.Booking_number = Randomizer(rand, 1000, 100000); booking.Client_code = client.Client_code; booking.Client = client; booking.Arrivall = DateTime.Parse(Arrival.Text); booking.DateOfBooking = DateTime.Today; booking.Departuree = DateTime.Parse(Departure.Text); booking.Pay = pay; booking.Payment_number = pay.Payment_number; booking.Room = room; booking.Room_code = room.Room_code; booking.TypeOfFood = type.Type_name; booking.TypeOfFood1 = type; Manipulation.db.Bookings.Add(booking); MessageBox.Show("Вы зарегестрировали бронь!"); Manipulation.db.SaveChanges(); Close(); } catch (NullReferenceException ex) { MessageBox.Show("Зaполните все данные!"); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { MessageBox.Show("Зaполните все данные!"); } catch (Exception exp) { MessageBox.Show(exp.Message); } }
async Task Booking() { try { if (SelectedHairstyle == null) { await Application.Current.MainPage.DisplayAlert("Error", "You must pick hairstyle which you want!", "OK"); return; } if (BookingTime.Hours < 8 || BookingTime.Hours > 16) { await Application.Current.MainPage.DisplayAlert("Error", "Working hours -> 8:00 AM - 17:00 PM", "OK"); return; } DateTime bookingStart = new DateTime(BookingDate.Year, BookingDate.Month, BookingDate.Day, BookingTime.Hours, BookingTime.Minutes, 0); BookingUpsertRequest booking = new BookingUpsertRequest { HairdresserId = _hairdresser.Id, HairstyleId = SelectedHairstyle.Id, UserId = _client.Id, StartDate = bookingStart, EndDate = bookingStart.AddMinutes(SelectedHairstyle.DurationOfProduction) }; Model.Booking newBooking = await _bookingApiService.Insert <Model.Booking>(booking); if (newBooking != null) { await Application.Current.MainPage.DisplayAlert("Success", "Booking added!", "OK"); if (await Application.Current.MainPage.DisplayAlert("Alert", "Would you like to add payment?", "Yes", "No")) { await Application.Current.MainPage.Navigation.PushModalAsync(new PaymentPage(new PaymentDto { ClientName = _client.FirstName + " " + _client.LastName, Purpose = SelectedHairstyle.HairstyleName, PaymentDate = DateTime.UtcNow, Price = SelectedHairstyle.Price })); } else { Application.Current.MainPage = new MainPage(); } } else { await Application.Current.MainPage.DisplayAlert("Error", "Booking failed! You have chosen a hairdresser who is busy at that time!", "Try again"); return; } } catch (Exception ex) { throw ex; } }
public List <Model.Room> GetAllRooms(string sortBy) { var entities = _dbContext.Rooms.ToList(); List <Model.Room> list = new List <Model.Room>(); if (entities != null) { foreach (var room in entities) { Model.Room hotelroom = new Model.Room(); hotelroom.Id = room.Id; hotelroom.HotelId = room.HotelId; hotelroom.Name = room.Name; hotelroom.Price = room.Price; hotelroom.IsActive = room.IsActive; hotelroom.CreatedBy = room.CreatedBy; hotelroom.CreatedDate = room.CreatedDate; hotelroom.CategoryId = room.CategoryId; hotelroom.Bookings = new List <Model.Booking>(); foreach (var booking in room.Bookings) { Model.Booking hotelroombooking = new Model.Booking(); hotelroombooking.Id = booking.Id; hotelroombooking.RoomId = booking.RoomId; hotelroombooking.Id = booking.Id; hotelroombooking.BookingDate = booking.BookingDate; hotelroombooking.BookingStatusId = booking.BookingStatusId; hotelroom.Bookings.Add(hotelroombooking); } list.Add(hotelroom); } } //sorting by city/pincode/category/price var hotelList = GetAllHotel(); List <Model.Room> sortedRoomList = new List <Model.Room>(); switch (sortBy) { case "city": hotelList = hotelList.OrderBy(o => o.City).ToList(); List <Model.Room> sortedBycityList = new List <Model.Room>(); foreach (var item in hotelList) { var roomList = list.Where(x => x.HotelId == item.Id).ToList(); foreach (var roomitem in roomList) { sortedBycityList.Add(roomitem); } } sortedRoomList = sortedBycityList; break; case "pincode": hotelList = hotelList.OrderBy(o => o.Pincode).ToList(); List <Model.Room> sortedByPincodeList = new List <Model.Room>(); foreach (var item in hotelList) { var roomList = list.Where(x => x.HotelId == item.Id).ToList(); foreach (var roomitem in roomList) { sortedByPincodeList.Add(roomitem); } } sortedRoomList = sortedByPincodeList; break; case "category": sortedRoomList = list.OrderBy(o => o.CategoryId).ToList(); break; default: sortedRoomList = list.OrderBy(o => o.Price).ToList(); break; } return(sortedRoomList); }