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);
     }
 }
 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 UpdateAuto(AutoDto autoToBeUpdated)
 {
     WriteActualMethod();
     try { autoManager.Update(autoToBeUpdated.ConvertToEntity()); }
     catch (OptimisticConcurrencyException <Auto> )
     {
         OptimisticConcurrencyFault ocf = new OptimisticConcurrencyFault
         {
             Operation   = "Update",
             ProblemType = "Optimstic Cocurrency Error during updating on Auto!"
         };
         throw new FaultException <OptimisticConcurrencyFault>(ocf);
     }
 }
 public void DeleteKunde(KundeDto kundeToBeDeleteed)
 {
     WriteActualMethod();
     try { kundeManager.Delete(kundeToBeDeleteed.ConvertToEntity()); }
     catch (OptimisticConcurrencyException <Kunde> )
     {
         OptimisticConcurrencyFault ocf = new OptimisticConcurrencyFault
         {
             Operation   = "Delete",
             ProblemType = "Optimstic Cocurrency Error during deleting on Kunde!"
         };
         throw new FaultException <OptimisticConcurrencyFault>(ocf);
     }
 }
 public void DeleteReservation(ReservationDto reservationToBeDeleteed)
 {
     WriteActualMethod();
     try { reservationManager.Delete(reservationToBeDeleteed.ConvertToEntity()); }
     catch (OptimisticConcurrencyException <Reservation> )
     {
         OptimisticConcurrencyFault ocf = new OptimisticConcurrencyFault
         {
             Operation   = "Delete",
             ProblemType = "Optimstic Cocurrency Error during deleting on Reservation!"
         };
         throw new FaultException <OptimisticConcurrencyFault>(ocf);
     }
 }
 private static TEntity handlingOptimisticConcurrencyException <TEntity>(string operation, Func <TEntity> func)
 {
     try
     {
         return(func());
     }
     catch (LocalOptimisticConcurrencyException <TEntity> e)
     {
         var fault = new OptimisticConcurrencyFault()
         {
             Message = "Concurrency error during " + operation
         };
         throw new FaultException <OptimisticConcurrencyFault>(fault);
     }
 }
Beispiel #7
0
        protected static void SaveChanges <T>(AutoReservationContext context, T entity) where T : class
        {
            try
            {
                context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                OptimisticConcurrencyFault ex = new OptimisticConcurrencyFault
                {
                    Message = "Unbekannter Concurrency Fehler"
                };

                throw new FaultException <OptimisticConcurrencyFault>(ex);
            }
        }
 public KundeDto UpdateKunde(KundeDto kunde)
 {
     WriteActualMethod();
     try
     {
         return(DtoConverter.ConvertToDto(kundeManager.UpdateKunde(DtoConverter.ConvertToEntity(kunde))));
     }
     catch (OptimisticConcurrencyException <Kunde> )
     {
         OptimisticConcurrencyFault <KundeDto> fault = new OptimisticConcurrencyFault <KundeDto>
         {
             FaultEntity   = kunde,
             CurrentEntity = DtoConverter.ConvertToDto(kundeManager.ReadKunde(kunde.Id))
         };
         throw new FaultException <OptimisticConcurrencyFault <KundeDto> >(fault);
     }
 }
 public AutoDto UpdateAuto(AutoDto auto)
 {
     WriteActualMethod();
     try
     {
         return(DtoConverter.ConvertToDto(autoManager.UpdateAuto(DtoConverter.ConvertToEntity(auto))));
     }
     catch (OptimisticConcurrencyException <Auto> )
     {
         OptimisticConcurrencyFault <AutoDto> fault = new OptimisticConcurrencyFault <AutoDto>
         {
             FaultEntity   = auto,
             CurrentEntity = DtoConverter.ConvertToDto(autoManager.ReadAuto(auto.Id))
         };
         throw new FaultException <OptimisticConcurrencyFault <AutoDto> >(fault);
     }
 }
Beispiel #10
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);
     }
 }