//method to make from reserve order booked order public void ResInBook(DateTime now, OrderStateHandler MakeOrder, OrderStateHandler cost, OrderStateHandler declain, OrderStateHandler confirm) { for (int i = 0; i < orders.Length; i++) { if (orders.Length != 0) { if (orders[i] is ReserveOrder && orders[i].Ind == now) { T newBorder = new BookOrder(Convert.ToString(orders[i].Name + "Booking"), orders[i].Phone, orders[i].Days, orders[i].Persons, orders[i].Type, orders[i].Ind, orders[i].Ind, orders[i].Room, orders[i].Wish) as T; Book(newBorder.Room); Declain(orders[i].Name, orders[i].Phone, orders[i].Room, orders[i].Wish); if (newBorder == null) { throw new Exception("order didn't make"); } if (orders == null) { orders = new T[] { newBorder } } ; else { T[] tempOrders = new T[orders.Length + 1]; for (int j = 0; j < orders.Length; j++) { tempOrders[j] = orders[j]; } tempOrders[tempOrders.Length - 1] = newBorder; orders = tempOrders; } newBorder.HowCost += cost; newBorder.IsDeclain += declain; newBorder.IsConfirm += confirm; newBorder.NewOrder += MakeOrder; newBorder.MakeOrder(); minusRoom(newBorder.Room); Confirm(newBorder.Name, newBorder.Phone); } } } }
//method to make order public void ToOrder(DateTime inDate, DateTime now, RoomType type, int days, int persons, UserWish wish, string name, string phone, OrderStateHandler MakeOrder, OrderStateHandler cost, OrderStateHandler declain, OrderStateHandler confirm) { T newOrder = null; int Wish = 0; // for choosing index of type of room switch (type) { case RoomType.Class: index_room = 2; break; case RoomType.Econom: index_room = 3; break; case RoomType.Lux: index_room = 1; break; } // choosing type of order switch (wish) { case UserWish.Booking: Wish = 1; newOrder = new BookOrder(name, phone, days, persons, type, now, inDate, index_room, Wish) as T; Book(index_room); break; case UserWish.Reservation: Wish = 2; newOrder = new ReserveOrder(name, phone, days, persons, type, now, inDate, index_room, Wish) as T; Reserve(index_room); break; } //making list of orders if (orders == null) { orders = new T[] { newOrder } } ; else { T[] tempOrders = new T[orders.Length + 1]; for (int j = 0; j < orders.Length; j++) { tempOrders[j] = orders[j]; } tempOrders[tempOrders.Length - 1] = newOrder; orders = tempOrders; } // making order and using method of class Order newOrder.HowCost += cost; newOrder.IsDeclain += declain; newOrder.IsConfirm += confirm; newOrder.NewOrder += MakeOrder; newOrder.MakeOrder(); minusRoom(index_room); //decrement available rooms }