public ReservationDto UpdateReservation(ReservationDto reservation)
 {
     WriteActualMethod();
     try
     {
         return(DtoConverter.ConvertToDto(reservationManager.Update(DtoConverter.ConvertToEntity(reservation))));
     }
     catch (OptimisticConcurrencyException <Reservation> )
     {
         OptimisticConcurrencyFault <ReservationDto> fault = new OptimisticConcurrencyFault <ReservationDto>
         {
             FaultEntity   = reservation,
             CurrentEntity = DtoConverter.ConvertToDto(reservationManager.GetById(reservation.ReservationsNr))
         };
         throw new FaultException <OptimisticConcurrencyFault <ReservationDto> >(fault);
     }
     catch (InvalidDateException <Reservation> )
     {
         DateRangeFault fault = new DateRangeFault
         {
             reservation = reservation
         };
         throw new FaultException <DateRangeFault>(fault);
     }
     catch (AutoUnavailableException <Reservation> )
     {
         AutoUnavailableFault fault = new AutoUnavailableFault
         {
             reservation = reservation
         };
         throw new FaultException <AutoUnavailableFault>(fault);
     }
 }
 public void UpdateReservation(ReservationDto reservationToBeUpdated)
 {
     WriteActualMethod();
     try { reservationManager.Update(reservationToBeUpdated.ConvertToEntity()); }
     catch (AutoUnavailableException)
     {
         AutoUnavailableFault auf = new AutoUnavailableFault
         {
             Operation   = "Insert",
             ProblemType = "Auto is not available during this Time Range!"
         };
         throw new FaultException <AutoUnavailableFault>(auf);
     }
     catch (InvalidDateRangeException)
     {
         InvalidDateRangeFault idf = new InvalidDateRangeFault
         {
             Operation   = "Insert",
             ProblemType = "Date is invalid!"
         };
         throw new FaultException <InvalidDateRangeFault>(idf);
     }
     catch (OptimisticConcurrencyException <Reservation> )
     {
         OptimisticConcurrencyFault ocf = new OptimisticConcurrencyFault
         {
             Operation   = "Update",
             ProblemType = "Optimstic Cocurrency Error during updating on Reservation!"
         };
         throw new FaultException <OptimisticConcurrencyFault>(ocf);
     }
 }
Example #3
0
 public void Insert(TDto dto)
 {
     try
     {
         WriteActualMethod();
         TEntity entity = Converter.ConvertToEntity(dto);
         Manager.Insert(entity);
     }
     catch (InvalidDateRangeException exception)
     {
         InvalidDateRangeFault fault = new InvalidDateRangeFault();
         fault.Operation   = "insert";
         fault.ProblemType = exception.Message;
         throw new FaultException <InvalidDateRangeFault>(fault);
     }
     catch (AutoUnavailableException exception)
     {
         AutoUnavailableFault fault = new AutoUnavailableFault();
         fault.Operation   = "insert";
         fault.ProblemType = exception.Message;
         throw new FaultException <AutoUnavailableFault>(fault);
     }
     catch (Exception exception)
     {
         UnknownFault fault = new UnknownFault();
         fault.Operation   = "insert";
         fault.ProblemType = exception.Message;
         throw new FaultException <UnknownFault>(fault);
     }
 }
        private static void checkForAvailabilityException(Reservation res)
        {
            DateTime wantedStart   = res.Von;
            DateTime wantedEnd     = res.Bis;
            int      myAuto        = res.AutoId;
            int      myReservation = res.ReservationsNr;



            List <Reservation> reservations = List;

            var reservedDates =
                from r in reservations
                where r.AutoId == myAuto && r.ReservationsNr != myReservation
                select new
            {
                r.Von,
                r.Bis
            };

            foreach (var reservedDate in reservedDates)
            {
                //ich reserviere, nachdem es jeman anders reserviert hat &&
                //der andere hat es noch nicht wieder zurückgegeben
                if (Overlap(reservedDate.Von, reservedDate.Bis, wantedStart, wantedEnd))
                {
                    AutoUnavailableFault fault = new AutoUnavailableFault();
                    fault.Message = alreadyReserved;
                    fault.Bis     = wantedEnd;
                    fault.Von     = wantedStart;
                    throw new FaultException <AutoUnavailableFault>(fault);
                }
            }
        }
Example #5
0
        public bool IsCarAvailable(int id, DateTime von, DateTime bis)
        {
            WriteActualMethod();
            try
            {
                return(_reservationManager.IsCarAvailable(id, von, bis));
            }
            catch (AutoUnavailableException)
            {
                AutoUnavailableFault fault = new AutoUnavailableFault()
                {
                    Operation = "Availability Check"
                };

                throw new FaultException <AutoUnavailableFault>(fault);
            }
        }
Example #6
0
        public void updateReservation(ReservationDto reservation)
        {
            WriteActualMethod();
            try
            {
                _reservationManager.UpdateReservation(reservation.ConvertToEntity());
            }
            catch (InvalidOperationException)
            {
                OutOfRangeFault fault = new OutOfRangeFault
                {
                    Operation = "update"
                };

                throw new FaultException <OutOfRangeFault>(fault);
            }
            catch (DbUpdateConcurrencyException)
            {
                ConcurrencyFault fault = new ConcurrencyFault();
                throw new FaultException <ConcurrencyFault>(fault);
            }
            catch (AutoUnavailableException)
            {
                AutoUnavailableFault fault = new AutoUnavailableFault()
                {
                    Operation = "update"
                };

                throw new FaultException <AutoUnavailableFault>(fault);
            }
            catch (InvalidDateRangeException)
            {
                InvalidDateRangeFault fault = new InvalidDateRangeFault()
                {
                    Operation = "update"
                };

                throw new FaultException <InvalidDateRangeFault>(fault);
            }
        }
 public void InsertReservation(ReservationDto reservationToBeInserted)
 {
     WriteActualMethod();
     try { reservationManager.Insert(reservationToBeInserted.ConvertToEntity()); }
     catch (AutoUnavailableException)
     {
         AutoUnavailableFault auf = new AutoUnavailableFault
         {
             Operation   = "Insert",
             ProblemType = "Auto is not available during this Time Range!"
         };
         throw new FaultException <AutoUnavailableFault>(auf);
     }
     catch (InvalidDateRangeException)
     {
         InvalidDateRangeFault idf = new InvalidDateRangeFault
         {
             Operation   = "Insert",
             ProblemType = "Date is invalid!"
         };
         throw new FaultException <InvalidDateRangeFault>(idf);
     }
 }
Example #8
0
 public void Update(TDto dto)
 {
     try
     {
         WriteActualMethod();
         TEntity entity = Converter.ConvertToEntity(dto);
         Manager.Update(entity);
     }
     catch (InvalidDateRangeException e)
     {
         InvalidDateRangeFault fault = new InvalidDateRangeFault();
         fault.Operation   = "update";
         fault.ProblemType = e.Message;
         throw new FaultException <InvalidDateRangeFault>(fault);
     }
     catch (AutoUnavailableException e)
     {
         AutoUnavailableFault fault = new AutoUnavailableFault();
         fault.Operation   = "update";
         fault.ProblemType = e.Message;
         throw new FaultException <AutoUnavailableFault>(fault);
     }
     catch (OptimisticConcurrencyException <TEntity> e)
     {
         OptimisticConcurrencyFault fault = new OptimisticConcurrencyFault();
         fault.Operation   = "update";
         fault.ProblemType = e.Message;
         throw new FaultException <OptimisticConcurrencyFault>(fault);
     }
     catch (Exception e)
     {
         UnknownFault fault = new UnknownFault();
         fault.Operation   = "update";
         fault.ProblemType = e.Message;
         throw new FaultException <UnknownFault>(fault);
     }
 }
 public ReservationDto InsertReservation(ReservationDto reservation)
 {
     WriteActualMethod();
     try
     {
         return(DtoConverter.ConvertToDto(reservationManager.Insert(DtoConverter.ConvertToEntity(reservation))));
     }
     catch (InvalidDateException <Reservation> )
     {
         DateRangeFault fault = new DateRangeFault
         {
             reservation = reservation
         };
         throw new FaultException <DateRangeFault>(fault);
     }
     catch (AutoUnavailableException <Reservation> )
     {
         AutoUnavailableFault fault = new AutoUnavailableFault
         {
             reservation = reservation
         };
         throw new FaultException <AutoUnavailableFault>(fault);
     }
 }
Example #10
0
 public void insertReservation(ReservationDto reservation)
 {
     WriteActualMethod();
     try
     {
         _reservationManager.AddReservation(reservation.ConvertToEntity());
     }
     catch (AutoUnavailableException)
     {
         AutoUnavailableFault fault = new AutoUnavailableFault()
         {
             Operation = "insert reservation"
         };
         throw new FaultException <AutoUnavailableFault>(fault);
     }
     catch (InvalidDateRangeException)
     {
         InvalidDateRangeFault fault = new InvalidDateRangeFault()
         {
             Operation = "insert reservation"
         };
         throw new FaultException <InvalidDateRangeFault>(fault);
     }
 }