/// <summary> /// Add a route to the database /// </summary> /// <parameter name="routeInfo"></parameter> /// <exception cref="RouteManagerException">Thrown when unable to add a route</exception> /// <returns>Returns the status of the insertion</returns> public bool AddRoute(Route routeInfo) { bool isRouteValid = false; isRouteValid = ValidateRouteInfo(routeInfo); if (isRouteValid) { try { int noOfRows = routeDAO.AddRoute(routeInfo); if (noOfRows > 0) { isRouteValid = true; } } catch (RouteDAOException ex) { //CSPRCR17.4 - Log an exception using the LogManager LogMessage message = new LogMessage(); message.ClassName = "RouteManager"; message.Message = ex.Message; message.MessageDateTime = DateTime.Now; message.MethodName = "AddRoute()"; message.ExceptionType = "RouteDAOException"; Logs.LogManager manager = new Logs.LogManager(Loggers.XML); manager.WriteToLog(message); throw new RouteManagerException("Unable to add route", ex); } } return(isRouteValid); }
/// <summary> /// Add a route to the database /// </summary> /// <parameter name="routeInfo"></parameter> /// <exception cref="RouteManagerException">Thrown when unable to add a route</exception> /// <returns>Returns the status of the insertion</returns> public bool AddRoute(Route routeInfo) { bool isRouteValid = false; isRouteValid = ValidateRouteInfo(routeInfo); Routes r = new Routes(); List <Route> lstr = r.GetRoutes(); foreach (var item in lstr) { if (routeInfo.ToCity.Name.Equals(item.ToCity.Name) && routeInfo.FromCity.Name.Equals(item.FromCity.Name)) { throw new RouteDAOException("Route already exists"); } } if (isRouteValid) { try { int noOfRows = routeDAO.AddRoute(routeInfo); if (noOfRows > 0) { isRouteValid = true; } } catch (RouteDAOException ex) { throw new RouteManagerException("Unable to add route", ex); } } return(isRouteValid); }
/// <summary> /// Add a route to the database /// </summary> /// <parameter name="routeInfo"></parameter> /// <exception cref="RouteManagerException">Thrown when unable to add a route</exception> /// <returns>Returns the status of the insertion</returns> public int AddRoute(Route routeInfo) { try { return(routeDAO.AddRoute(routeInfo)); } catch (RouteDAOException ex) { throw new RouteManagerException("Unable to add route", ex); } }
/// <summary> /// Add a route to the database /// </summary> /// <parameter name="routeInfo"></parameter> /// <exception cref="RouteManagerException">Thrown when unable to add a route</exception> /// <returns>Returns the status of the insertion</returns> public bool AddRoute(Route routeInfo) { bool isRouteValid = false; isRouteValid = ValidateRouteInfo(routeInfo); if (isRouteValid) { try { int noOfRows = routeDAO.AddRoute(routeInfo); if (noOfRows > 0) { isRouteValid = true; } } catch (RouteDAOException ex) { throw new RouteManagerException("Unable to add route", ex); } } return(isRouteValid); }