/// <summary> /// Update the existing flight details along with seats and class /// </summary> /// <parameter name="flightClassInfo"></parameter> /// <parameter name="flightInfo"></parameter> /// <exception cref="FlightManagerException">Thorwn when unable to update flight class</exception> /// <returns>Returns the status of the update</returns> public int UpdateFlightClass(Flight flightInfo, FlightClass flightClassInfo) { try { return(flightDAO.UpdateFlightClass(flightInfo, flightClassInfo)); } catch (FlightDAOException ex) { throw new FlightManagerException("Unable to update flight class", ex); } }
/// <summary> /// Update the existing flight details along with seats and class /// </summary> /// <parameter name="flightClassInfo"></parameter> /// <parameter name="flightInfo"></parameter> /// <exception cref="FlightManagerException">Thorwn when unable to update flight class</exception> /// <returns>Returns the status of the update</returns> public int UpdateFlightClass(Flight flightInfo, FlightClass flightClassInfo) { try { AppSettingsReader asr = new AppSettingsReader(); string[] tokens = asr.GetValue("flightclasses", typeof(string)).ToString().Split(';'); if (tokens.Length > 0 && (tokens.Length % 2 == 0)) { int i = 0; List <FlightClass> fcs = flightInfo.GetClasses(); foreach (FlightClass fc in fcs) { string[] fcTokens = tokens[i].Split(':'); if (fc.ClassInfo.ToString().ToLower().Equals(fcTokens[0].ToLower())) { int maxSeats = Convert.ToInt16(fcTokens[1]); if (fc.NoOfSeats > maxSeats) { throw new FlightManagerException("The maximum seats for " + fc.ClassInfo.ToString() + " has exceeded"); } } i++; } } else { throw new FlightManagerException("Invalid flight class configuration. Please check the config file"); } return(flightDAO.UpdateFlightClass(flightInfo, flightClassInfo)); } catch (FlightManagerException) { throw; } catch (FlightDAOException ex) { throw new FlightManagerException("Unable to update flight class", ex); } }