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; } }
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; } }