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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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)));
            }
        }
Ejemplo n.º 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)));
            }
        }
Ejemplo n.º 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)));
            }
        }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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)));
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 10
0
 public void Delete(ExitRamp exitRamp)
 {
     CrudFactory.Delete(exitRamp);
 }