Ejemplo n.º 1
0
        private VehicleTypeDTO Create(VehicleTypeViewModel viewModel)
        {
            try
            {
                log.Debug(VehicleTypeViewModel.FormatVehicleTypeViewModel(viewModel));

                VehicleTypeDTO vehicleType = new VehicleTypeDTO();

                // copy values
                viewModel.UpdateDTO(vehicleType, null); //RequestContext.Principal.Identity.GetUserId());

                // audit
                vehicleType.CreateBy = null; //RequestContext.Principal.Identity.GetUserId();
                vehicleType.CreateOn = DateTime.UtcNow;

                // add
                log.Debug("_vehicleTypeService.AddVehicleType - " + VehicleTypeDTO.FormatVehicleTypeDTO(vehicleType));

                int id = _vehicleTypeService.AddVehicleType(vehicleType);

                vehicleType.VehicleTypeId = id;

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

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

                throw;
            }
        }
Ejemplo n.º 2
0
        public VehicleTypeDTO GetVehicleType(int vehicleTypeId)
        {
            try
            {
                //Requires.NotNegative("vehicleTypeId", vehicleTypeId);

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

                // get
                R_VehicleType t = Repository.GetVehicleType(vehicleTypeId);

                VehicleTypeDTO dto = new VehicleTypeDTO(t);

                log.Debug(VehicleTypeDTO.FormatVehicleTypeDTO(dto));

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

                throw;
            }
        }
Ejemplo n.º 3
0
        public int AddVehicleType(VehicleTypeDTO dto)
        {
            int id = 0;

            try
            {
                log.Debug(VehicleTypeDTO.FormatVehicleTypeDTO(dto));

                R_VehicleType t = VehicleTypeDTO.ConvertDTOtoEntity(dto);

                // add
                id = Repository.AddVehicleType(t);
                dto.VehicleTypeId = id;

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

                throw;
            }

            return(id);
        }
Ejemplo n.º 4
0
        private VehicleTypeDTO Update(VehicleTypeViewModel viewModel)
        {
            try
            {
                log.Debug(VehicleTypeViewModel.FormatVehicleTypeViewModel(viewModel));

                // get
                log.Debug("_vehicleTypeService.GetVehicleType - vehicleTypeId: " + viewModel.VehicleTypeId + " ");

                var existingVehicleType = _vehicleTypeService.GetVehicleType(viewModel.VehicleTypeId);

                log.Debug("_vehicleTypeService.GetVehicleType - " + VehicleTypeDTO.FormatVehicleTypeDTO(existingVehicleType));

                if (existingVehicleType != null)
                {
                    // copy values
                    viewModel.UpdateDTO(existingVehicleType, null); //RequestContext.Principal.Identity.GetUserId());

                    // update
                    log.Debug("_vehicleTypeService.UpdateVehicleType - " + VehicleTypeDTO.FormatVehicleTypeDTO(existingVehicleType));

                    _vehicleTypeService.UpdateVehicleType(existingVehicleType);

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

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

                throw;
            }
        }
Ejemplo n.º 5
0
        public void DeleteVehicleType(VehicleTypeDTO dto)
        {
            try
            {
                log.Debug(VehicleTypeDTO.FormatVehicleTypeDTO(dto));

                R_VehicleType t = VehicleTypeDTO.ConvertDTOtoEntity(dto);

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

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

                throw;
            }
        }
Ejemplo n.º 6
0
        public void UpdateVehicleType(VehicleTypeDTO dto)
        {
            try
            {
                //Requires.NotNull(t);
                //Requires.PropertyNotNegative(t, "VehicleTypeId");

                log.Debug(VehicleTypeDTO.FormatVehicleTypeDTO(dto));

                R_VehicleType t = VehicleTypeDTO.ConvertDTOtoEntity(dto);

                // update
                Repository.UpdateVehicleType(t);

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

                throw;
            }
        }