Example #1
0
        public PlannedRouteDTO GetPlannedRoute(int plannedRouteId)
        {
            try
            {
                //Requires.NotNegative("plannedRouteId", plannedRouteId);

                log.Debug("plannedRouteId: " + plannedRouteId + " ");

                // get
                R_PlannedRoute t = Repository.GetPlannedRoute(plannedRouteId);

                PlannedRouteDTO dto = new PlannedRouteDTO(t);

                log.Debug(PlannedRouteDTO.FormatPlannedRouteDTO(dto));

                return(dto);
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
Example #2
0
        public int AddPlannedRoute(PlannedRouteDTO dto)
        {
            int id = 0;

            try
            {
                log.Debug(PlannedRouteDTO.FormatPlannedRouteDTO(dto));

                R_PlannedRoute t = PlannedRouteDTO.ConvertDTOtoEntity(dto);

                // add
                id = Repository.AddPlannedRoute(t);
                dto.PlannedRouteId = id;

                log.Debug("result: 'success', id: " + id);
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }

            return(id);
        }
Example #3
0
        private PlannedRouteDTO Update(PlannedRouteViewModel viewModel)
        {
            try
            {
                log.Debug(PlannedRouteViewModel.FormatPlannedRouteViewModel(viewModel));

                // get
                log.Debug("_plannedRouteService.GetPlannedRoute - plannedRouteId: " + viewModel.PlannedRouteId + " ");

                var existingPlannedRoute = _plannedRouteService.GetPlannedRoute(viewModel.PlannedRouteId);

                log.Debug("_plannedRouteService.GetPlannedRoute - " + PlannedRouteDTO.FormatPlannedRouteDTO(existingPlannedRoute));

                if (existingPlannedRoute != null)
                {
                    // copy values
                    existingPlannedRoute.Name              = viewModel.Name;
                    existingPlannedRoute.RouteTypeId       = viewModel.RouteTypeId;
                    existingPlannedRoute.TransportTypeId   = viewModel.TransportTypeId;
                    existingPlannedRoute.Description       = viewModel.Description;
                    existingPlannedRoute.StartHour         = viewModel.StartHour;
                    existingPlannedRoute.EstimatedDuration = viewModel.EstimatedDuration;
                    existingPlannedRoute.TotalDistance     = viewModel.TotalDistance;
                    existingPlannedRoute.RouteDayOfTheWeek = viewModel.RouteDayOfTheWeek;
                    existingPlannedRoute.Active            = viewModel.Active;
                    existingPlannedRoute.IsDeleted         = viewModel.IsDeleted;

                    // audit
                    //existingPlannedRoute.UpdateBy = UserInfo.UserID;
                    existingPlannedRoute.UpdateOn = DateTime.UtcNow;

                    // update
                    log.Debug("_plannedRouteService.UpdatePlannedRoute - " + PlannedRouteDTO.FormatPlannedRouteDTO(existingPlannedRoute));

                    _plannedRouteService.UpdatePlannedRoute(existingPlannedRoute);

                    log.Debug("result: 'success'");
                }
                else
                {
                    log.Error("existingPlannedRoute: null, PlannedRouteId: " + viewModel.PlannedRouteId);
                }

                return(existingPlannedRoute);
            }
            catch (Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
Example #4
0
        private PlannedRouteDTO Create(PlannedRouteViewModel viewModel)
        {
            try
            {
                log.Debug(PlannedRouteViewModel.FormatPlannedRouteViewModel(viewModel));

                PlannedRouteDTO plannedRoute = new PlannedRouteDTO();

                // copy values
                plannedRoute.PlannedRouteId    = viewModel.PlannedRouteId;
                plannedRoute.Name              = viewModel.Name;
                plannedRoute.RouteTypeId       = viewModel.RouteTypeId;
                plannedRoute.TransportTypeId   = viewModel.TransportTypeId;
                plannedRoute.Description       = viewModel.Description;
                plannedRoute.StartHour         = viewModel.StartHour;
                plannedRoute.EstimatedDuration = viewModel.EstimatedDuration;
                plannedRoute.TotalDistance     = viewModel.TotalDistance;
                plannedRoute.RouteDayOfTheWeek = viewModel.RouteDayOfTheWeek;
                plannedRoute.Active            = viewModel.Active;
                plannedRoute.IsDeleted         = viewModel.IsDeleted;


                // audit
                //plannedRoute.CreateBy = UserInfo.UserID;
                //plannedRoute.UpdateBy = UserInfo.UserID;
                plannedRoute.CreateOn = DateTime.UtcNow;
                plannedRoute.UpdateOn = DateTime.UtcNow;

                // add
                log.Debug("_plannedRouteService.AddPlannedRoute - " + PlannedRouteDTO.FormatPlannedRouteDTO(plannedRoute));

                int id = _plannedRouteService.AddPlannedRoute(plannedRoute);

                plannedRoute.PlannedRouteId = id;

                log.Debug("result: 'success', id: " + id);

                return(plannedRoute);
            }
            catch (Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
Example #5
0
        public void DeletePlannedRoute(PlannedRouteDTO dto)
        {
            try
            {
                log.Debug(PlannedRouteDTO.FormatPlannedRouteDTO(dto));

                R_PlannedRoute t = PlannedRouteDTO.ConvertDTOtoEntity(dto);

                // delete
                Repository.DeletePlannedRoute(t);
                dto.IsDeleted = t.IsDeleted;

                log.Debug("result: 'success'");
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
Example #6
0
        public void UpdatePlannedRoute(PlannedRouteDTO dto)
        {
            try
            {
                //Requires.NotNull(t);
                //Requires.PropertyNotNegative(t, "PlannedRouteId");

                log.Debug(PlannedRouteDTO.FormatPlannedRouteDTO(dto));

                R_PlannedRoute t = PlannedRouteDTO.ConvertDTOtoEntity(dto);

                // update
                Repository.UpdatePlannedRoute(t);

                log.Debug("result: 'success'");
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }