public Dashboard() { InitializeComponent(); currentUser = (User)Application.Current.Properties["user"]; usersManager = new UserManager(); userList = new List <User>(); routesList = new List <Route>(); routeManager = new RouteManager(); reservationsList = new List <Reservation>(); reservationManager = new ReservationManager(); routesListView.ItemTemplate = new DataTemplate(typeof(RoutesCell)); routesListView.ItemTapped += RoutesListView_ItemTapped; routesListView.Refreshing += RoutesListView_Refreshing; reservationsButton = new ToolbarItem { Name = "Reservations", Command = new Command(this.Reservations), Order = ToolbarItemOrder.Primary, Priority = 3 }; }
public frmShowReservations(Room room) { InitializeComponent(); _roomId = room.Id; _reservationService = new ReservationManager(new EfReservationDal()); _guestService = new GuestManager(new EfGuestDal()); }
public ActionResult RoomDate(ReservationAuditoriumDay model) { string[] parse = model.date.Split(' '); string[] parts = parse[parse.Length - 1].Split('.'); int year = int.Parse(parts[2]), month = int.Parse(parts[1]), day = int.Parse(parts[0]); DateTime date = new DateTime(year, month, day, 0, 0, 0); ReservationManager reservManager = new ReservationManager(date); if (model.auditorium != null) { reservManager.Table = new List <List <TD> >(); reservManager.Table = reservManager.GetDayRoomReservation(date, model.auditorium); ViewBag.id = "td-day"; ViewBag.Room = model.auditorium; ViewBag.Date = date; } else { ViewBag.id = "td"; ViewBag.Auditoriums = db.Auditorium; } return(PartialView("Table", reservManager)); }
public void addRerservation(ReservationDto reservationDto) { WriteActualMethod(); Reservation reservation = DtoConverter.ConvertToEntity(reservationDto); ReservationManager reservationManager = new ReservationManager(); try { reservationManager.addReservation(reservation); } catch (InvalidDateRangeException <Reservation> e) { InvalidDateRange fault = new InvalidDateRange(); fault.Result = false; fault.Message = e.Message; fault.Description = "Ungültiger Zeitraum gewählt!"; throw new FaultException <InvalidDateRange>(fault); } catch (AutoUnavailableException <Auto> e) { AutoUnavailable fault = new AutoUnavailable(); fault.Result = false; fault.Message = e.Message; fault.Description = "Car is not available"; throw new FaultException <AutoUnavailable>(fault); } }
public ReservationController(UserManager <User> userManager, ReservationManager reservationManager, VmManager vmManager) { _userManager = userManager; _reservationManager = reservationManager; _vmManager = vmManager; }
public ActionResult FinalizeReservation(string dateStart, string dateEnd, string totalPrice, string[] selectedRooms) { /* * 1) add dateStart, dateEnd, totalPrice and idClient in table Reservation * 2) retrieve last idReservation and save it * 3) loop through listOfRooms and each time call BLL.UpdateRoomReservation to insert idRoom and IdReservation * */ int[] arrayIdRooms = new int[selectedRooms.Length]; //extract all idrooms selected and put them in an array for (int i = 0; i < selectedRooms.Length; i++) { arrayIdRooms[i] = Convert.ToInt32(selectedRooms[i].ToString()); } Client client = (Client)Session["IdClient"]; //convert strings to appropriate formats DateTime dateStartUsable = Convert.ToDateTime(dateStart.ToString()); DateTime dateEndUsable = Convert.ToDateTime(dateEnd.ToString()); decimal totalPriceUsable = Convert.ToDecimal(totalPrice.ToString()); //step 1 ReservationManager.AddNewReservation(client.Idclient, dateStartUsable, dateEndUsable, totalPriceUsable); //step 2 int idReservation = ReservationManager.GetLastIdReservation(); //step 3 for (int i = 0; i < arrayIdRooms.Length; i++) { ReservationManager.AddNewRoomReservation(arrayIdRooms[i], idReservation); } return(View("Final")); }
public ReservationDto getReservationByNr(int nr) { WriteActualMethod(); ReservationManager reservationManager = new ReservationManager(); return(DtoConverter.ConvertToDto(reservationManager.getReservationByNr(nr))); }
public static bool DebugDrawReservations(ReservationManager __instance) { foreach (Reservation reservation in getAllReservations(__instance)) { if (reservation.Target.Thing != null) { if (reservation.Target.Thing.Spawned) { Thing thing = reservation.Target.Thing; Vector3 s = new Vector3(thing.RotatedSize.x, 1f, thing.RotatedSize.z); Matrix4x4 matrix = default; matrix.SetTRS(thing.DrawPos + Vector3.up * 0.1f, Quaternion.identity, s); Graphics.DrawMesh(MeshPool.plane10, matrix, DebugReservedThingIcon, 0); GenDraw.DrawLineBetween(reservation.Claimant.DrawPos, reservation.Target.Thing.DrawPos); } else { Graphics.DrawMesh(MeshPool.plane03, reservation.Claimant.DrawPos + Vector3.up + new Vector3(0.5f, 0f, 0.5f), Quaternion.identity, DebugReservedThingIcon, 0); } } else { Graphics.DrawMesh(MeshPool.plane10, reservation.Target.Cell.ToVector3ShiftedWithAltitude(AltitudeLayer.MetaOverlays), Quaternion.identity, DebugReservedThingIcon, 0); GenDraw.DrawLineBetween(reservation.Claimant.DrawPos, reservation.Target.Cell.ToVector3ShiftedWithAltitude(AltitudeLayer.MetaOverlays)); } } return(false); }
public void CreateNewOverviewTest_CreatesOverViewAndCalculatesRight() { ReservationManager rm = new ReservationManager(new UnitOfWork(new ReservationContextTest())); FindReservationViewModel mockViewModel = new FindReservationViewModel(rm); Client client = new Client(999, "Alice", "Cards", ClientCategory.Vip, new Address()); rm.AddClient(client); Location start = Location.Antwerpen; Location stop = Location.Brussel; List <Price> prices = new List <Price>(); prices.Add(new Price(Arrangement.Airport, 100m)); prices.Add(new Price(Arrangement.Business, 100m)); prices.Add(new Price(Arrangement.NightLife, 900m)); prices.Add(new Price(Arrangement.Wedding, 800m)); prices.Add(new Price(Arrangement.Wellness, 750m)); Car car = new Car("RabbitHole", "Delux", "Brown", prices); DeliveryAddress address = new DeliveryAddress("Teaparty", "1", "Wonderland"); rm.AddCar(car); DateTime startTime = new DateTime(2020, 12, 12, 8, 0, 0); Arrangement arrangement = Arrangement.Airport; DateTime endTime = new DateTime(2020, 12, 12, 12, 0, 0); ReservationOverview reservationOverview = rm.CreateOverview(rm.CreateReservation(client, start, stop, car, startTime, arrangement, endTime, address)); reservationOverview.TotalNormal.ShouldBe(295m); reservationOverview.TotalBeforeDiscount.ShouldBe(295m); reservationOverview.Tax.ShouldBe(18m); reservationOverview.TotalToPay.ShouldBe(313m); }
public static bool ReleaseAllClaimedBy(ReservationManager __instance, Pawn claimant) { Dictionary <Pawn, List <Reservation> > reservationClaimantDict = getReservationClaimantDict(__instance); lock (__instance) { Dictionary <LocalTargetInfo, List <Reservation> > reservationTargetDict = getReservationTargetDict(__instance); List <Reservation> reservationClaimantList = getReservationClaimantList(reservationClaimantDict, claimant); foreach (Reservation reservation in reservationClaimantList) { List <Reservation> reservationTargetList = getReservationTargetList(reservationTargetDict, reservation.Target); List <Reservation> newReservationTargetList = new List <Reservation>(); for (int index = 0; index < reservationTargetList.Count; index++) { Reservation reservation2 = reservationTargetList[index]; if (reservation2.Claimant != claimant) { newReservationTargetList.Add(reservation2); } } reservationTargetDict[reservation.Target] = newReservationTargetList; //HaulingCache if (reservation.Target.Thing != null && reservation.Target.Thing.def.EverHaulable && reservation.Target.Thing.Map != null) { HaulingCache.ReregisterHaulableItem(reservation.Target.Thing); } } reservationClaimantDict[claimant] = new List <Reservation>(); } return(false); }
private static IEnumerable <Thing> AllReservedThings2(ReservationManager __instance) { foreach (Reservation reservation in getAllReservations(__instance)) { yield return(reservation.Target.Thing); } }
public static void PostReleaseAllForTarget(ReservationManager __instance, LocalTargetInfo target, Pawn claimant, Job job) { if (target.Thing != null && target.Thing.def.EverHaulable && target.Thing.Map != null) { HaulingCache.ReregisterHaulableItem(target.Thing); } }
public ReservationDto GetReservation(int id) { WriteActualMethod(); ReservationManager manager = new ReservationManager(); return(DtoConverter.ConvertToDto(manager.GetReservation(id))); }
public List <ReservationDto> GetAllReservations() { WriteActualMethod(); ReservationManager manager = new ReservationManager(); return(DtoConverter.ConvertToDtos(manager.ListOfReservationen)); }
public static bool Release(ReservationManager __instance, LocalTargetInfo target, Pawn claimant, Job job) { if (target.ThingDestroyed) { Log.Warning("Releasing destroyed thing " + target + " for " + claimant); } Reservation reservation1 = null; Reservation reservation2; for (int index = 0; index < reservations(__instance).Count; ++index) { try { reservation2 = reservations(__instance)[index]; } catch (ArgumentOutOfRangeException) { break; } if (reservation2.Target == target && reservation2.Claimant == claimant && reservation2.Job == job) { reservation1 = reservation2; break; } } if (reservation1 == null && !target.ThingDestroyed) { Log.Error("Tried to release " + target + " that wasn't reserved by " + claimant + ".", false); } else { lock (reservations(__instance)) { reservations(__instance).Remove(reservation1); } } return(false); }
private static bool Prefix(ref bool __result, ReservationManager __instance, Pawn claimant, LocalTargetInfo target, out bool __state, int maxPawns = 1, int stackCount = -1, ReservationLayerDef layer = null, bool ignoreOtherReservations = false) { __state = false; if (claimant.RaceProps.Humanlike) { if (target.HasThing && target.thingInt.Map != null && target.thingInt.Map != claimant.Map) { var cell = ZUtils.GetCellToTeleportFrom(claimant.Map, claimant.Position, target.thingInt.Map); if (cell.IsValid) { __state = true; oldMap = claimant.Map; oldPosition = claimant.Position; ZUtils.TeleportThing(claimant, target.thingInt.Map, cell); ZLogger.Message($"Teleporting claimaint {claimant} to {target.thingInt.Map}"); __result = claimant.CanReserve(target, maxPawns, stackCount, layer, ignoreOtherReservations); return(false); } else { ZLogger.Pause($"CanReserve: Detected reservation disfunction: pawn: {claimant}, thing: {target.thingInt}, pawn.Map: {claimant.Map}, thing.Map: {target.thingInt.Map}"); } } } return(true); }
public ActionResult Removal() { // Je récupère les informations saisies par l'utilisateur (en minuscules, afin d'éviter les problèmes de casse) string firstname = Request["firstname"].ToLower(); string lastname = Request["lastname"].ToLower(); int identity = Convert.ToInt32(Request["number"]); // Je teste ensuite si les informations saisies correspondent à une réservation (comme une sorte de login) // Si c'est en ordre, je lance les deux requêtes de suppression Boolean login = ReservationManager.LoginReservation(identity, firstname, lastname); if (login.Equals(true)) { ReservationManager.RemoveReservation(identity); ReservationDetailsManager.RemoveReservationDetails(identity); } // Je passe ensuite la valeur du booléen login à la vue, afin d'afficher le bon encadré // Je passe également les informations de la réservation, afin de les afficher ViewData["login"] = login; ReservationVM reservation = new ReservationVM { IdReservation = identity, ClientFirstname = Request["firstname"], ClientLastname = Request["lastname"] }; return(View(reservation)); }
private static void Postfix(ReservationManager __instance, Pawn claimant, LocalTargetInfo target, ref bool __state, int maxPawns = 1, ReservationLayerDef layer = null, bool ignoreOtherReservations = false) { if (__state) { ZUtils.TeleportThing(claimant, oldMap, claimant.Position); } }
public static IEnumerable <Thing> FindThingsOfTypeNextTo(Map map, IntVec3 position, int distance) { int minX = Math.Max(0, position.x - distance); int maxX = Math.Min(map.info.Size.x, position.x + distance); int minZ = Math.Max(0, position.z - distance); int maxZ = Math.Min(map.info.Size.z, position.z + distance); ReservationManager rsvmgr = map.reservationManager; List <Thing> list = new List <Thing>(); for (int x = minX - 1; x <= maxX; ++x) { for (int z = minZ - 1; z <= maxZ; ++z) { foreach (Thing t in map.thingGrid.ThingsAt(new IntVec3(x, position.y, z))) { if (rsvmgr == null || !rsvmgr.IsReservedByAnyoneOf(new LocalTargetInfo(t), Faction.OfPlayer)) { list.Add(t); } } } } return(list); }
public ActionResult CreateReservation(ReservationSelection resSelection) { if (User.Identity.IsAuthenticated) { //on vérifie la cohérence des dates + présence de chambres if (resSelection.FirstNight.Date > resSelection.LastNight.Date || resSelection.RoomsId.Count == 0 || resSelection.FirstNight.Date < DateTime.Now.Date ) { TempData["error"] = "Incohérence détectée dans les données"; return(RedirectToAction("_ReservationFailed")); } List <Room> selectedRoom = new List <Room>(); //on vérifie si les chambres sont toujours libre List <Room> emptyRooms = RoomManager.GetAllEmptyRoomsAtDateRange(resSelection.FirstNight, resSelection.LastNight); foreach (int selRoomId in resSelection.RoomsId) { bool isFree = emptyRooms .Where(r => r.IdRoom == selRoomId) .Count() > 0; if (!isFree) { TempData["error"] = "Une des chambres choisies n'est plus disponible."; return(RedirectToAction("_ReservationFailed")); } //on peuple déjà la liste des chambres choisies pour la future insertion selectedRoom.Add( emptyRooms .Where(r => r.IdRoom == selRoomId) .ToList() .FirstOrDefault() ); } Reservation reservation = new Reservation { FirstNight = resSelection.FirstNight, LastNight = resSelection.LastNight, IdUser = ((UserData)Session["UserData"]).IdUser, Rooms = selectedRoom }; //on re-calcule le prix actuel, hack javascript... reservation.Price = ReservationManager.GetInstantPriceFromReservation(reservation); //insertion de la réservation dans la base et récupération de l'id reservation.IdReservation = ReservationManager.SaveReservation(reservation); TempData["reservation"] = reservation; return(Redirect("/Reservation/_ConfirmedReservation")); } else { return(RedirectToAction("_Login", "ModalLogin")); } }
public bool isCarAvailable(ReservationDto reservation, AutoDto auto) { WriteActualMethod(); ReservationManager reservationManager = new ReservationManager(); return(reservationManager.IsCarAvailable(DtoConverter.ConvertToEntity(reservation), DtoConverter.ConvertToEntity(auto))); }
public ActionResult Validate() { ReservationVM reservation = (ReservationVM)TempData["Reservation"]; TempData["Reservation"] = reservation; List <Room> rooms = new List <Room>(); foreach (int id in reservation.RoomIds) { Room room = RoomManager.GetRoom(id); rooms.Add(room); } ReservationValidateVM reservationValidate = new ReservationValidateVM(); reservationValidate.Arrival = reservation.Arrival; reservationValidate.Departure = reservation.Departure; reservationValidate.TotalNight = ReservationManager.GetNumberOfNight(reservation.Arrival, reservation.Departure); reservationValidate.FirstName = reservation.Firstname; reservationValidate.LastName = reservation.Lastname; reservationValidate.Rooms = rooms; reservationValidate.TotalPrice = ReservationManager.CalculatePrice(reservation.RoomIds, reservation.Arrival, reservation.Departure); reservationValidate.RoomNumber = rooms.Count(); ViewBag.ReservationValidate = reservationValidate; return(View(reservation)); }
public List <ReservationDto> getAllReservations() { WriteActualMethod(); ReservationManager reservationManager = new ReservationManager(); return(DtoConverter.ConvertToDtos(reservationManager.List)); }
/// <summary> /// Display reservation details (Hotle, room, reservation info, ...) when the user is authorized /// </summary> public ActionResult Details(int id) { //Check if session exist if (Session["IsAuthorized"] != null) { bool isAuthorized = Convert.ToBoolean(Session["IsAuthorized"]); //check session status, if true get data and display it if (isAuthorized) { Reservation reservation = ReservationManager.GetReservation(id); ReservationValidateVM reservationValidate = new ReservationValidateVM(); reservationValidate.Arrival = reservation.Arrival; reservationValidate.Departure = reservation.Departure; reservationValidate.TotalNight = ReservationManager.GetNumberOfNight(reservation.Arrival, reservation.Departure); reservationValidate.FirstName = reservation.Client.Firstname; reservationValidate.LastName = reservation.Client.Lastname; reservationValidate.Rooms = reservation.Rooms; reservationValidate.TotalPrice = ReservationManager.CalculatePrice(reservation.Rooms, reservation.Arrival, reservation.Departure); reservationValidate.RoomNumber = reservation.Rooms.Count(); ViewBag.ReservationValidate = reservationValidate; return(View()); } } return(RedirectToAction("Index")); }
public void SelectAllReserved() { Find.Selector.ClearSelection(); ReservationManager res = pawn.Map.reservationManager; foreach (Thing thing in res.AllReservedThings().Where(t => res.ReservedBy(t, pawn) && t.Spawned)) Find.Selector.Select(thing); }
public static bool FirstRespectedReserver(ReservationManager __instance, ref Pawn __result, LocalTargetInfo target, Pawn claimant) { if (!target.IsValid) { __result = null; return(false); } Reservation reservation; for (int i = 0; i < reservations(__instance).Count; i++) { try { reservation = reservations(__instance)[i]; } catch (ArgumentOutOfRangeException) { break; } if (null == reservation) { continue; } if (reservation.Target == target && RespectsReservationsOf(claimant, reservation.Claimant)) { __result = reservation.Claimant; return(false); } } __result = null; return(false); }
public ActionResult Index() { //для инициализации бд //DBInitialization init = new DBInitialization(); //init.Initialization(db); try { if (Session["IsAuthenticated"] == null) { Session["IsAuthenticated"] = false; } } catch { Session["IsAuthenticated"] = false; } ReservationManager reservManager = new ReservationManager(DateTime.Now); ViewBag.Auditoriums = db.Auditorium; ViewBag.id = "td"; return(View(reservManager)); }
public static bool FirstReservationFor(ReservationManager __instance, ref LocalTargetInfo __result, Pawn claimant) { if (claimant == null) { __result = LocalTargetInfo.Invalid; return(false); } //ReservationManager.Reservation[] reservations2 = reservations(__instance).ToArray(); ReservationManager.Reservation r; for (int i = 0; i < reservations(__instance).Count; i++) { try { r = reservations(__instance)[i]; } catch (ArgumentOutOfRangeException) { break; } if (null != r) { if (r.Claimant == claimant) { __result = r.Target; return(false); } } } __result = LocalTargetInfo.Invalid; return(false); }
public ActionResult RemoveReservation(ReservationForChange reservForRemote) { int rId = int.Parse(reservForRemote.reservation); IQueryable <Reservation> reservations = db.Reservation.Where(r => r.ReservationId.Equals(rId)); Reservation reserv = new Reservation(); foreach (Reservation r in reservations) { reserv = r; } db.RemoveReservation(reserv); ReservationManager reservManager = new ReservationManager(reserv.StartDate); if (reservForRemote.view == 0) { ViewBag.id = "td"; ViewBag.Auditoriums = db.Auditorium; } else if (reservForRemote.view == 1) { IQueryable <Auditorium> auditorium = db.Auditorium.Where(auditor => auditor.AuditoriumId.Equals(reserv.TargetAuditorium)); foreach (Auditorium a in auditorium) { reservManager.Table = new List <List <TD> >(); reservManager.Table = reservManager.GetDayRoomReservation(reserv.StartDate, a.AuditoriumName); ViewBag.id = "td-day"; ViewBag.Room = a.AuditoriumName; ViewBag.Date = reserv.StartDate; ViewBag.Auditoriums = db.Auditorium.Where(auditor => auditor.AuditoriumName.Equals(a.AuditoriumName)); } } else if (reservForRemote.view == 2) { IQueryable <Auditorium> auditorium = db.Auditorium.Where(auditor => auditor.AuditoriumId.Equals(reserv.TargetAuditorium)); foreach (Auditorium a in auditorium) { reservManager.Table = new List <List <TD> >(); reservManager.Table = reservManager.GetWeekReservation(reserv.StartDate, a.AuditoriumName); ViewBag.id = "td"; ViewBag.week = reservManager.GetDays(reserv.StartDate); } } return(PartialView("Table", reservManager)); }
public override async Task <Empty> Update(ReservationDto request, ServerCallContext context) { ReservationManager manager = new ReservationManager(); Reservation reservation = request.ConvertToEntity(); try { await manager.Update(reservation); } catch (OptimisticConcurrencyException <Reservation> exception) { throw new RpcException(new Status( StatusCode.Aborted, "Conccurency Exception" ), exception.ToString()); } catch (InvalidDateRangeException exception) { throw new RpcException(new Status( StatusCode.FailedPrecondition, "From-To must be at least 24 hours apart" ), exception.ToString()); } catch (AutoUnavailableException exception) { throw new RpcException(new Status( StatusCode.FailedPrecondition, "Car is not available" ), exception.ToString()); } return(new Empty()); }