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);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
            }
        }
Example #4
0
        // 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)));
            }
        }
Example #5
0
        // 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)));
            }
        }
Example #6
0
        // 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)));
            }
        }
Example #7
0
 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);
     }
 }
Example #8
0
        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)));
            }
        }
Example #9
0
        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);
        }
Example #10
0
 public void Delete(ExitRamp exitRamp)
 {
     CrudFactory.Delete(exitRamp);
 }