public BaseEntity BuildObject(Dictionary <string, object> row) { var terminal = new Terminal { IdTerminal = GetIntValue(row, DB_COL_ID_TERMINAL) }; var currentBus = new Bus { IdBus = GetIntValue(row, DB_COL_ID_CURRENT_BUS) }; var nextBus = new Bus { IdBus = GetIntValue(row, DB_COL_ID_NEXT_BUS) }; var route = new Route { IdRoute = GetIntValue(row, DB_COL_ID_ROUTE) }; var exitRamp = new ExitRamp { IdExitRamp = GetIntValue(row, DB_COL_ID), Name = GetStringValue(row, DB_COL_NAME), Terminal = terminal, Route = route }; return(exitRamp); }
private ExitRamp BuildEntities(ExitRamp pExitRamp) { if (pExitRamp.Terminal.IdTerminal > 0) { pExitRamp.Terminal = TerminalMng.RetrieveById(pExitRamp.Terminal); } if (pExitRamp.Route.IdRoute > 0) { pExitRamp.Route = RouteFactory.Retrieve <Route>(pExitRamp.Route); if (pExitRamp.Route != null) { pExitRamp.TravelList = TravelMng.RetrieveTravelByRoute(pExitRamp.Route); var nextTravels = TravelMng.FindNextTravels(pExitRamp.TravelList); if (nextTravels.Count > 0) { pExitRamp.CurrentTravel = nextTravels?[0]; if (nextTravels.Count > 1) { pExitRamp.NextTravel = nextTravels?[1]; } } } } return(pExitRamp); }
public void Update(ExitRamp exitRamp) { ExitRamp be = null; try { be = CrudFactory.Retrieve <ExitRamp>(exitRamp); if (be != null) { if (!String.IsNullOrEmpty(exitRamp.Name)) { CrudFactory.Update(exitRamp); } else { // Both ExitRamp Name and Terminal ID are required. throw new BusinessException(29); } } else { // ExitRamp Not Found. throw new BusinessException(28); } } catch (Exception ex) { ExceptionManager.GetInstance().Process(ex); } }
// DELETE @ api/exitRamp public IHttpActionResult Delete(ExitRamp exitRamp) { try { mng.Delete(exitRamp); apiResp = new ApiResponse(); apiResp.Message = "Eliminación Exitosa: Rampa de Salida"; return(Ok(apiResp)); } catch (BusinessException bex) { return(InternalServerError(new Exception(bex.ExceptionId + "-" + bex.AppMessage.Message))); } }
// POST @ api/exitRamp public IHttpActionResult Post(ExitRamp exitRamp) { try { mng.Create(exitRamp); apiResp = new ApiResponse(); apiResp.Message = "Registro Exitoso: Rampa de Salida"; return(Ok(apiResp)); } catch (BusinessException bex) { return(InternalServerError(new Exception(bex.ExceptionId + "-" + bex.AppMessage.Message))); } }
// PUT @ api/exitRamp public IHttpActionResult Put(ExitRamp exitRamp) { try { //exitRamp = mng.RetrieveById(exitRamp); mng.Update(exitRamp); apiResp = new ApiResponse(); apiResp.Message = "Actualización Exitosa: Rampa de Salida"; return(Ok(apiResp)); } catch (BusinessException bex) { return(InternalServerError(new Exception(bex.ExceptionId + "-" + bex.AppMessage.Message))); } }
public void Create(ExitRamp exitRamp) { try { if (!String.IsNullOrEmpty(exitRamp.Name) && exitRamp.Terminal.IdTerminal > 0) { CrudFactory.Create(exitRamp); } else { // Both ExitRamp Name and Terminal ID are required. throw new BusinessException(29); } } catch (Exception ex) { ExceptionManager.GetInstance().Process(ex); } }
public IHttpActionResult RetrieveById(int pIdExitRamp) { try { var exitRamp = new ExitRamp { IdExitRamp = pIdExitRamp }; exitRamp = mng.RetrieveById(exitRamp); apiResp = new ApiResponse(); apiResp.Message = "Consulta Exitosa: Rampa de Salida"; apiResp.Data = exitRamp; return(Ok(apiResp)); } catch (BusinessException bex) { return(InternalServerError(new Exception(bex.ExceptionId + "-" + bex.AppMessage.Message))); } }
public ExitRamp RetrieveById(ExitRamp exitRamp) { ExitRamp be = null; try { be = CrudFactory.Retrieve <ExitRamp>(exitRamp); if (be != null) { BuildEntities(be); } else { // ExitRamp Not Found. throw new BusinessException(28); } } catch (Exception ex) { ExceptionManager.GetInstance().Process(ex); } return(be); }
public void Delete(ExitRamp exitRamp) { CrudFactory.Delete(exitRamp); }