public void GetDefaultLoadDetails_LoadIDNotGreaterThenZero(int id) { var searchBaseLoadRequestDto = new SearchBaseLoadRequestDto { LoadID = id }; var result = _adminLoadProcessor.GetDefaultLoadDetails(searchBaseLoadRequestDto); }
public HttpResponseMessage GetDefaultLoadDetails(SearchBaseLoadRequestDto searchBasicLoadDto) { return(CreateHttpResponse(() => { var adminLoadDefaultDto = _adminLoadProcessor.GetDefaultLoadDetails(searchBasicLoadDto); PickListDetailForDefaultLoad(adminLoadDefaultDto, searchBasicLoadDto.LoadFamilyID); return Request.CreateResponse(adminLoadDefaultDto); })); }
public void GetDefaultLoadDetails_LoadNotFound(int id) { var searchBaseLoadRequestDto = new SearchBaseLoadRequestDto { LoadID = id }; _loadDefaultsRepository.GetSingle(p => p.ID == searchBaseLoadRequestDto.ID && p.Active). ReturnsForAnyArgs(LoadDefaultList().FirstOrDefault(x => x.ID == searchBaseLoadRequestDto.ID)); var result = _adminLoadProcessor.GetDefaultLoadDetails(searchBaseLoadRequestDto); }
public ACLoadDto GetLoadDetailsForACLoad(SearchBaseLoadRequestDto searchACLoadDto, string userName) { var solutionLoadDefaultDetail = _loadDefaultsRepository.GetSingle(l => l.LoadID == searchACLoadDto.LoadID); if (solutionLoadDefaultDetail == null) { throw new PowerDesignProException("LoadNotFound", Message.SolutionLoad); } var voltageFrequencyDetail = _solutionSetupRepository.GetAll(x => x.SolutionID == searchACLoadDto.SolutionID) .Select(r => new { VoltageSpecific = r.VoltageSpecific.Value, Frequency = r.Frequency.Value }).FirstOrDefault(); var voltageSpecific = voltageFrequencyDetail.VoltageSpecific; var frequency = voltageFrequencyDetail.Frequency; solutionLoadDefaultDetail.ID = 0; if (searchACLoadDto.ID != 0) { var acLoadDetail = _acLoadRepository.GetSingle(x => x.ID == searchACLoadDto.ID); if (acLoadDetail == null) { throw new PowerDesignProException("ACLoadNotFound", Message.SolutionLoad); } var result = _acLoadEntityToacLoadDtoMapper.AddMap(acLoadDetail, userName: userName); result.VoltageSpecific = int.Parse(voltageSpecific); result.Frequency = int.Parse(frequency); return(result); } else { var result = _loadDefaultsEntityToACLoadDtoMapper.AddMap(solutionLoadDefaultDetail); if (result != null) { var countLoad = _acLoadRepository.GetAll(x => x.LoadID == solutionLoadDefaultDetail.LoadID && x.SolutionID == searchACLoadDto.SolutionID).Count(); result.Description = string.Concat(solutionLoadDefaultDetail.Load.Description, " #", countLoad + 1); result.VoltageSpecific = int.Parse(voltageSpecific); result.Frequency = int.Parse(frequency); return(result); } } return(new ACLoadDto()); }
public void GetDefaultLoadDetails_Successfully(int id) { var searchBaseLoadRequestDto = new SearchBaseLoadRequestDto { LoadID = id }; _loadDefaultsRepository.GetSingle(p => p.LoadID == searchBaseLoadRequestDto.LoadID). ReturnsForAnyArgs(LoadDefaultList().FirstOrDefault(x => x.LoadID == searchBaseLoadRequestDto.LoadID)); var result = _adminLoadProcessor.GetDefaultLoadDetails(searchBaseLoadRequestDto); Assert.AreEqual(result.ID, id); }
public HttpResponseMessage GetSolutionLoadDetails(int solutionId, int loadId, int loadFamilyId, int?solutionLoadId = 0) { return(CreateHttpResponse(() => { var requestDto = new SearchBaseLoadRequestDto { ID = solutionLoadId, LoadID = loadId, SolutionID = solutionId, LoadFamilyID = loadFamilyId }; switch (loadFamilyId) { case (int)SolutionLoadFamilyEnum.Basic: { var basicLoadDto = _solutionLoadProcessor.GetLoadDetailsForBasicLoad(requestDto, UserName); LoadPickListDetailForBasicLoad(basicLoadDto.BasicLoadPickListDto); return Request.CreateResponse(basicLoadDto); } case (int)SolutionLoadFamilyEnum.AC: { var acLoadDto = _solutionLoadProcessor.GetLoadDetailsForACLoad(requestDto, UserName); LoadPickListDetailForACLoad(acLoadDto.ACLoadPickListDto); return Request.CreateResponse(acLoadDto); } case (int)SolutionLoadFamilyEnum.Lighting: { var acLoadDto = _solutionLoadProcessor.GetLoadDetailsForLightingLoad(requestDto, UserName); LoadPickListDetailForLightingLoad(acLoadDto.LightingLoadPickListDto); return Request.CreateResponse(acLoadDto); } case (int)SolutionLoadFamilyEnum.UPS: { var upsLoadDto = _solutionLoadProcessor.GetLoadDetailsForUpsLoad(requestDto, UserName); LoadPickListDetailForUpsLoad(upsLoadDto.UPSLoadPickListDto); return Request.CreateResponse(upsLoadDto); } case (int)SolutionLoadFamilyEnum.Welder: { var welderLoadDto = _solutionLoadProcessor.GetLoadDetailsForWelderLoad(requestDto, UserName); LoadPickListDetailForWelderLoad(welderLoadDto.WelderLoadPickListDto); return Request.CreateResponse(welderLoadDto); } case (int)SolutionLoadFamilyEnum.Motor: { var motorLoadDto = _solutionLoadProcessor.GetLoadDetailsForMotorLoad(requestDto, UserName); LoadPickListDetailForMotorLoad(motorLoadDto.MotorLoadPickListDto); return Request.CreateResponse(motorLoadDto); } default: return null; } })); }
public MotorLoadDto GetLoadDetailsForMotorLoad(SearchBaseLoadRequestDto searchMotorLoadDto, string userName) { var solutionLoadDefaultDetail = _loadDefaultsRepository.GetSingle(l => l.LoadID == searchMotorLoadDto.LoadID); if (solutionLoadDefaultDetail == null) { throw new PowerDesignProException("LoadNotFound", Message.SolutionLoad); } var voltageFrequencyDetail = _solutionSetupRepository.GetAll(x => x.SolutionID == searchMotorLoadDto.SolutionID) .Select(r => new { r.VoltagePhaseID, r.VoltageNominalID, r.VoltageSpecificID, r.FrequencyID, r.Frequency.Value }).FirstOrDefault(); solutionLoadDefaultDetail.ID = 0; if (searchMotorLoadDto.ID != 0) { var motorLoadDetail = _motorLoadRepository.GetSingle(x => x.ID == searchMotorLoadDto.ID); if (motorLoadDetail == null) { throw new PowerDesignProException("MotorLoadNotFound", Message.SolutionLoad); } var result = _motorLoadEntityToMotorLoadDtoMapper.AddMap(motorLoadDetail, userName: userName); result.Frequency = Convert.ToInt32(voltageFrequencyDetail.Value); result.StartingMethodEditable = solutionLoadDefaultDetail.StartingMethodEditable; result.ConfigurationInputEditable = solutionLoadDefaultDetail.ConfigurationInputEditable; result.MotorLoadLevelEditable = solutionLoadDefaultDetail.MotorLoadLevelEditable; result.MotorLoadTypeEditable = solutionLoadDefaultDetail.MotorLoadTypeEditable; result.MotorTypeEditable = solutionLoadDefaultDetail.MotorTypeEditable; result.StartingCodeEditable = solutionLoadDefaultDetail.StartingCodeEditable; result.SizeRunningEditable = solutionLoadDefaultDetail.SizeRunningEditable; result.HarmonicTypeEditable = solutionLoadDefaultDetail.HarmonicTypeEditable; result.FrequencyID = voltageFrequencyDetail.FrequencyID; return(result); } else { var result = _loadDefaultsEntityToMotorLoadDtoMapper.AddMap(solutionLoadDefaultDetail); if (result != null) { var countLoad = _motorLoadRepository.GetAll(x => x.LoadID == solutionLoadDefaultDetail.LoadID && x.SolutionID == searchMotorLoadDto.SolutionID).Count(); result.Description = string.Concat(solutionLoadDefaultDetail.Load.Description, " #", countLoad + 1); var voltageNominalSpecificLoads = GetVoltageNominalSpecificForLoads(voltageFrequencyDetail.VoltageNominalID, voltageFrequencyDetail.VoltageSpecificID, voltageFrequencyDetail.VoltagePhaseID, voltageFrequencyDetail.FrequencyID); result.VoltagePhaseID = voltageFrequencyDetail.VoltagePhaseID; result.VoltageNominalID = voltageNominalSpecificLoads.VoltageNominalID; result.VoltageSpecificID = voltageNominalSpecificLoads.VoltageSpecificID; result.Frequency = Convert.ToInt32(voltageFrequencyDetail.Value); result.FrequencyID = voltageFrequencyDetail.FrequencyID; result.HarmonicContentID = solutionLoadDefaultDetail.HarmonicDeviceType.HarmonicContentID; result.StartingMethodID = solutionLoadDefaultDetail.StartingMethodID; return(result); } } return(new MotorLoadDto()); }
public BasicLoadDto GetLoadDetailsForBasicLoad(SearchBaseLoadRequestDto searchBasicLoadDto, string userName) { var solutionLoadDefaultDetail = _loadDefaultsRepository.AllIncluding(x => x.HarmonicDeviceType) .Where(l => l.LoadID == searchBasicLoadDto.LoadID).FirstOrDefault(); var voltageFrequencyDetail = _solutionSetupRepository.GetAll(x => x.SolutionID == searchBasicLoadDto.SolutionID) .Select(r => new { r.VoltagePhaseID, r.VoltageNominalID, r.VoltageSpecificID, r.FrequencyID, r.Frequency.Value }).FirstOrDefault(); if (solutionLoadDefaultDetail == null) { throw new PowerDesignProException("LoadNotFound", Message.SolutionLoad); } solutionLoadDefaultDetail.ID = 0; if (searchBasicLoadDto.ID != 0) { var basicLoadDetail = _basicLoadRepository.GetSingle(x => x.ID == searchBasicLoadDto.ID); if (basicLoadDetail == null) { throw new PowerDesignProException("BasicLoadNotFound", Message.SolutionLoad); } var result = _basicLoadEntityToBasicLoadDtoMapper.AddMap(basicLoadDetail, userName: userName); result.FrequencyID = voltageFrequencyDetail.FrequencyID; result.Frequency = Convert.ToInt32(voltageFrequencyDetail.Value); //result.HarmonicContentID = solutionLoadDefaultDetail.HarmonicDeviceType.HarmonicContentID; result.RunningPFEditable = solutionLoadDefaultDetail.RunningPFEditable; result.SizeStartingEditable = solutionLoadDefaultDetail.SizeStartingEditable; result.SizeRunningEditable = solutionLoadDefaultDetail.SizeRunningEditable; result.StartingPFEditable = solutionLoadDefaultDetail.StartingPFEditable; result.HarmonicTypeEditable = solutionLoadDefaultDetail.HarmonicTypeEditable; result.StartingMethodID = solutionLoadDefaultDetail.StartingMethodID; result.PFStarting = basicLoadDetail.StartingPF != null?Convert.ToDecimal(basicLoadDetail.StartingPF.Value) : 0; result.PFRunning = basicLoadDetail.RunningPF != null?Convert.ToDecimal(basicLoadDetail.RunningPF.Value) : 0; result.SizeRunningUnits = basicLoadDetail.SizeRunningUnits?.Value; result.SizeStartingUnits = basicLoadDetail.SizeRunningUnits?.Value; result.VoltagePhase = basicLoadDetail.VoltagePhase != null?Convert.ToInt32(basicLoadDetail.VoltagePhase.Value) : 0; result.VoltageSpecific = basicLoadDetail.VoltageSpecific != null?Convert.ToInt32(basicLoadDetail.VoltageSpecific.Value) : 0; result.LoadSequenceType = basicLoadDetail.Sequence?.SequenceType.Value; return(result); } else { var result = _loadDefaultsEntityToBasicLoadDtoMapper.AddMap(solutionLoadDefaultDetail); if (result != null) { var countLoad = _basicLoadRepository.GetAll(x => x.LoadID == solutionLoadDefaultDetail.LoadID && x.SolutionID == searchBasicLoadDto.SolutionID).Count(); result.Description = string.Concat(solutionLoadDefaultDetail.Load.Description, " #", countLoad + 1); var voltageNominalSpecificLoads = GetVoltageNominalSpecificForLoads(voltageFrequencyDetail.VoltageNominalID, voltageFrequencyDetail.VoltageSpecificID, voltageFrequencyDetail.VoltagePhaseID, voltageFrequencyDetail.FrequencyID); result.VoltagePhaseID = voltageFrequencyDetail.VoltagePhaseID; result.VoltageNominalID = voltageNominalSpecificLoads.VoltageNominalID; result.VoltageSpecificID = voltageNominalSpecificLoads.VoltageSpecificID; result.FrequencyID = voltageFrequencyDetail.FrequencyID; result.Frequency = Convert.ToInt32(voltageFrequencyDetail.Value); result.HarmonicContentID = solutionLoadDefaultDetail.HarmonicDeviceType.HarmonicContentID; result.StartingMethodID = solutionLoadDefaultDetail.StartingMethodID; return(result); } } return(new BasicLoadDto()); }