public List <VehicleSpectDto> GetVehicleSpect() { var data = _VehicleSpectService.GetVehicleSpect(); var retData = Mapper.Map <List <VehicleSpectDto> >(data); foreach (VehicleSpectDto item in retData) { item.FuelTypeSpect = data.Where(x => x.MST_VEHICLE_SPECT_ID == item.MstVehicleSpectId).First().FUEL_TYPE; } return(retData); }
public void CheckTempInProgress() { var dateMinus1 = DateTime.Now.AddDays(-1); var allTemp = _TemporaryService.GetAllTemp().Where(x => x.VENDOR_CONTRACT_START_DATE != null).ToList(); var listTempInProgress = allTemp.Where(x => x.DOCUMENT_STATUS == Enums.DocumentStatus.InProgress && x.VENDOR_CONTRACT_START_DATE.Value.Day == dateMinus1.Day && x.VENDOR_CONTRACT_START_DATE.Value.Month == dateMinus1.Month && x.VENDOR_CONTRACT_START_DATE.Value.Year == dateMinus1.Year && !string.IsNullOrEmpty(x.VENDOR_PO_NUMBER)).ToList(); foreach (var item in listTempInProgress) { //change status completed var input = new TempWorkflowDocumentInput(); input.ActionType = Enums.ActionType.Completed; input.UserId = "SYSTEM"; input.DocumentId = item.TRA_TEMPORARY_ID; input.DocumentNumber = item.DOCUMENT_NUMBER; TempWorkflow(input); //add new master fleet MST_FLEET dbFleet; var getZonePriceList = _locationMappingService.GetLocationMapping().Where(x => x.BASETOWN == item.LOCATION_CITY && x.IS_ACTIVE).FirstOrDefault(); var zonePrice = getZonePriceList == null ? "" : getZonePriceList.ZONE_PRICE_LIST; var priceList = _priceListService.GetPriceList().Where(x => x.YEAR == item.CREATED_DATE.Year && x.MANUFACTURER == item.VENDOR_MANUFACTURER && x.MODEL == item.VENDOR_MODEL && x.SERIES == item.VENDOR_SERIES && x.IS_ACTIVE && x.ZONE_PRICE_LIST == zonePrice).FirstOrDefault(); var vSpecList = _vehicleSpectService.GetVehicleSpect().Where(x => x.YEAR == item.CREATED_DATE.Year && x.MANUFACTURER == item.MANUFACTURER && x.MODEL == item.MODEL && x.SERIES == item.SERIES && x.BODY_TYPE == item.BODY_TYPE && x.IS_ACTIVE).FirstOrDefault(); var functionList = _groupCostService.GetGroupCostCenter().Where(x => x.COST_CENTER == item.COST_CENTER).FirstOrDefault(); var vehType = string.Empty; var vehUsage = string.Empty; var projectName = string.Empty; var isProject = false; var hmsPrice = priceList == null ? 0 : priceList.INSTALLMEN_HMS; var address = getZonePriceList == null ? "" : getZonePriceList.ADDRESS; var regional = getZonePriceList == null ? "" : getZonePriceList.REGION; var function = functionList == null ? "" : functionList.FUNCTION_NAME; var fuelType = vSpecList == null ? string.Empty : vSpecList.FUEL_TYPE; if (!string.IsNullOrEmpty(item.VEHICLE_TYPE)) { var vehTypeData = _settingService.GetSettingById(Convert.ToInt32(item.VEHICLE_TYPE)); if (vehTypeData != null) { vehType = vehTypeData.SETTING_VALUE.ToUpper(); } } if (!string.IsNullOrEmpty(item.VEHICLE_USAGE)) { var vehUsageData = _settingService.GetSettingById(Convert.ToInt32(item.VEHICLE_USAGE)); if (vehUsageData != null) { vehUsage = vehUsageData.SETTING_VALUE.ToUpper(); } } if (!string.IsNullOrEmpty(item.PROJECT_NAME)) { var projectNameData = _settingService.GetSettingById(Convert.ToInt32(item.PROJECT_NAME)); if (projectNameData != null) { projectName = projectNameData.SETTING_VALUE.ToUpper(); isProject = true; } } dbFleet = Mapper.Map <MST_FLEET>(item); dbFleet.IS_ACTIVE = true; dbFleet.CREATED_DATE = DateTime.Now; dbFleet.VEHICLE_TYPE = vehType; dbFleet.VEHICLE_USAGE = vehUsage; dbFleet.SUPPLY_METHOD = "TEMPORARY"; dbFleet.PROJECT = isProject; dbFleet.PROJECT_NAME = projectName; dbFleet.MONTHLY_HMS_INSTALLMENT = hmsPrice; dbFleet.TOTAL_MONTHLY_CHARGE = hmsPrice + (item.VAT_DECIMAL == null ? 0 : item.VAT_DECIMAL.Value); dbFleet.FUEL_TYPE = fuelType; dbFleet.ADDRESS = address; dbFleet.REGIONAL = regional; dbFleet.VEHICLE_FUNCTION = function; _fleetService.save(dbFleet); _uow.SaveChanges(); } }