public void Save_WorkTargetValueIsZero_ThrowsDomainException() { var request = new AssetFuelBurnRateSettingRequest { AssetUIds = new List <string>(this._assetUIDs.Select(x => x.ToString())), CustomerUid = this._customerUid, UserUid = this._userUid, IdleTargetValue = -1, WorkTargetValue = 0, TargetValues = new Dictionary <AssetTargetType, double?> { { AssetTargetType.IdlingBurnRateinLiPerHour, -1 }, { AssetTargetType.WorkingBurnRateinLiPerHour, 0 } } }; try { var result = this._assetSettingsService.Save(request).Result; } catch (AggregateException aggregateEx) { Assert.NotNull(aggregateEx.InnerException); var domainEx = (DomainException)aggregateEx.InnerException; Assert.NotNull(domainEx); Assert.NotNull(domainEx.Errors); Assert.Equal(domainEx.Errors.First().ErrorCode, (int)ErrorCodes.IdleValueShouldNotBeNegative); Assert.Equal(domainEx.Errors.First().Message, UtilHelpers.GetEnumDescription(ErrorCodes.IdleValueShouldNotBeNegative)); } }
public void Save_AssetUIDNull_ThrowsDomainException() { var request = new AssetFuelBurnRateSettingRequest { AssetUIds = null, CustomerUid = this._customerUid, UserUid = this._userUid, IdleTargetValue = 100, WorkTargetValue = 1000, TargetValues = new Dictionary <AssetTargetType, double?> { { AssetTargetType.IdlingBurnRateinLiPerHour, 100 }, { AssetTargetType.WorkingBurnRateinLiPerHour, 1000 } } }; try { var result = this._assetSettingsService.Save(request).Result; } catch (AggregateException aggregateEx) { Assert.NotNull(aggregateEx.InnerException); var domainEx = (DomainException)aggregateEx.InnerException; Assert.NotNull(domainEx); Assert.NotNull(domainEx.Errors); Assert.Equal(domainEx.Errors.First().ErrorCode, (int)ErrorCodes.AssetUIDListNull); Assert.Equal(domainEx.Errors.First().Message, UtilHelpers.GetEnumDescription(ErrorCodes.AssetUIDListNull)); } }
public void Save_InvalidAssetUIDInAssetUIDs_ThrowsDomainException() { var request = new AssetFuelBurnRateSettingRequest { AssetUIds = new List <string>(this._assetUIDs.Take(2).Select(x => x.ToString())), CustomerUid = this._customerUid, UserUid = this._userUid, TargetValues = new Dictionary <AssetTargetType, double?> { { AssetTargetType.IdlingBurnRateinLiPerHour, 100 }, { AssetTargetType.WorkingBurnRateinLiPerHour, 1000 } }, IdleTargetValue = 100, WorkTargetValue = 1000 }; var invalidAssetUID = Guid.NewGuid().ToString(); try { request.AssetUIds.Add(invalidAssetUID); var result = this._assetSettingsService.Save(request).Result; } catch (AggregateException aggregateEx) { Assert.NotNull(aggregateEx.InnerException); var domainEx = (DomainException)aggregateEx.InnerException; Assert.NotNull(domainEx); Assert.NotNull(domainEx.Errors); Assert.Equal(domainEx.Errors.First().ErrorCode, (int)ErrorCodes.InvalidAssetUID); Assert.Equal(domainEx.Errors.First().Message, string.Format(UtilHelpers.GetEnumDescription(ErrorCodes.InvalidAssetUID), invalidAssetUID)); } }
public void Fetch_InvalidAllAssetUIDs_ThrowsDomainException() { var request = new AssetFuelBurnRateSettingRequest { AssetUIds = null, IdleTargetValue = 100, WorkTargetValue = 1000, TargetValues = new Dictionary <AssetTargetType, double?> { { AssetTargetType.IdlingBurnRateinLiPerHour, 100 }, { AssetTargetType.WorkingBurnRateinLiPerHour, 1000 } }, CustomerUid = this._customerUid, UserUid = this._userUid }; var invalidAssetUID = new[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; try { request.AssetUIds = invalidAssetUID.ToList(); var result = this._assetSettingsService.Fetch(request).Result; } catch (AggregateException aggregateEx) { Assert.NotNull(aggregateEx.InnerException); var domainEx = (DomainException)aggregateEx.InnerException; Assert.NotNull(domainEx); Assert.NotNull(domainEx.Errors); Assert.Equal(domainEx.Errors.First().ErrorCode, (int)ErrorCodes.InvalidAssetUID); Assert.Equal(domainEx.Errors.First().Message, string.Format(UtilHelpers.GetEnumDescription(ErrorCodes.InvalidAssetUID), string.Join(",", invalidAssetUID))); } }
public static IEnumerable <object[]> GetAssetDeviceTypeRequest() { return(new List <object[]> { new object[] { new AssetDeviceTypeRequest() { UserUid = Guid.NewGuid() }, (int)ErrorCodes.CustomerUIDNull, UtilHelpers.GetEnumDescription(ErrorCodes.CustomerUIDNull) }, new object[] { new AssetDeviceTypeRequest() { CustomerUid = Guid.NewGuid(), }, (int)ErrorCodes.UserUIDNull, UtilHelpers.GetEnumDescription(ErrorCodes.UserUIDNull) }, new object[] { new AssetDeviceTypeRequest() { UserUid = Guid.NewGuid(), CustomerUid = Guid.NewGuid() }, 0, null } }); }
public void Save_TargetValueNegative_ThrowsDomainException() { var request = new AssetSettingsRequest { AssetUIds = new List <string>(this._assetUIDs.Select(x => x.ToString())), CustomerUid = this._customerUid, UserUid = this._userUid, TargetValues = new Dictionary <AssetTargetType, double?> { { AssetTargetType.BucketVolumeinCuMeter, -1 } } }; try { var result = this._assetSettingsService.Save(request).Result; } catch (AggregateException aggregateEx) { Assert.NotNull(aggregateEx.InnerException); var domainEx = (DomainException)aggregateEx.InnerException; Assert.NotNull(domainEx); Assert.NotNull(domainEx.Errors); Assert.Equal(domainEx.Errors.First().ErrorCode, (int)ErrorCodes.TargetValueIsNegative); Assert.Equal(domainEx.Errors.First().Message, UtilHelpers.GetEnumDescription(ErrorCodes.TargetValueIsNegative)); } }
protected virtual void CheckForInvalidRecords(AssetSettingsRequestBase request, List <IErrorInfo> errorInfos) { var invalidRecords = errorInfos.Where(x => x.IsInvalid); if (errorInfos.Where(x => x.IsInvalid).Any()) { this._loggingService.Info("Ignoring request since following records are invalid : " + JsonConvert.SerializeObject(invalidRecords), MethodInfo.GetCurrentMethod().Name); throw new DomainException { Errors = errorInfos }; } if (request.AssetUIds == null || !request.AssetUIds.Any()) { throw new DomainException { Errors = errorInfos.Any() ? errorInfos : new List <IErrorInfo> { new ErrorInfo { ErrorCode = (int)ErrorCodes.AssetUIDListNull, Message = UtilHelpers.GetEnumDescription(ErrorCodes.AssetUIDListNull) } } }; } }
public void Save_InvalidAllAssetUIDs_ThrowsDomainException() { var request = new AssetSettingsRequest { AssetUIds = null, CustomerUid = this._customerUid, UserUid = this._userUid, TargetValues = new Dictionary <AssetTargetType, double?> { { AssetTargetType.BucketVolumeinCuMeter, 100 } } }; var invalidAssetUID = new[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; try { request.AssetUIds = invalidAssetUID.ToList(); var result = this._assetSettingsService.Save(request).Result; } catch (AggregateException aggregateEx) { Assert.NotNull(aggregateEx.InnerException); var domainEx = (DomainException)aggregateEx.InnerException; Assert.NotNull(domainEx); Assert.NotNull(domainEx.Errors); Assert.Equal(domainEx.Errors.First().ErrorCode, (int)ErrorCodes.InvalidAssetUID); Assert.Equal(domainEx.Errors.First().Message, string.Format(UtilHelpers.GetEnumDescription(ErrorCodes.InvalidAssetUID), string.Join(",", invalidAssetUID))); } }
public async Task <IList <IErrorInfo> > Validate(AssetSettingsRequestBase request) { var result = new List <IErrorInfo>(); if (request.AssetUIds != null && request.AssetUIds.Count() > 0) { if (request.CustomerUid.HasValue && request.UserUid.HasValue) { var validAssetUids = await this._assetSettingsListRepository.FetchValidAssetUIds(request.AssetUIds, new AssetSettingsListRequestDto { CustomerUid = request.CustomerUid.Value.ToString("N"), UserUid = request.UserUid.Value.ToString("N"), StatusInd = 1 }); if (validAssetUids != null) { validAssetUids = validAssetUids.Select(x => Guid.Parse(x).ToString()); } var invalidAssetUids = request.AssetUIds.Except(validAssetUids); if (invalidAssetUids.Count() > 0) { result.AddRange(base.GetValidationResults(ErrorCodes.InvalidAssetUID, invalidAssetUids, UtilHelpers.GetEnumDescription(ErrorCodes.InvalidAssetUID), false, MethodInfo.GetCurrentMethod().Name)); request.AssetUIds.RemoveAll(invalidAssetUids.Contains); } } } else { result.Add(base.GetValidationResult(ErrorCodes.AssetUIDListNull, UtilHelpers.GetEnumDescription(ErrorCodes.AssetUIDListNull), false, MethodInfo.GetCurrentMethod().Name)); } return(result.Count > 0 ? result : null); }
public void Fetch_InvalidAssetUIDInAssetUIDs_ThrowsDomainException() { var request = new AssetSettingsRequest { AssetUIds = new List <string>(this._assetUIDs.Take(2).Select(x => x.ToString())), CustomerUid = this._customerUid, UserUid = this._userUid, TargetValues = new Dictionary <AssetTargetType, double?> { { AssetTargetType.BucketVolumeinCuMeter, 123.2 } }, }; var invalidAssetUID = Guid.NewGuid().ToString(); try { request.AssetUIds.Add(invalidAssetUID); var result = this._assetSettingsService.Fetch(request).Result; } catch (AggregateException aggregateEx) { Assert.NotNull(aggregateEx.InnerException); var domainEx = (DomainException)aggregateEx.InnerException; Assert.NotNull(domainEx); Assert.NotNull(domainEx.Errors); Assert.Equal(domainEx.Errors.First().ErrorCode, (int)ErrorCodes.InvalidAssetUID); Assert.Equal(domainEx.Errors.First().Message, string.Format(UtilHelpers.GetEnumDescription(ErrorCodes.InvalidAssetUID), invalidAssetUID)); } }
public void FetchEssentialAssets_InvalidFilterName_ThrowsDomainException() { try { var response = _assetSettingsListService.FetchEssentialAssets(new AssetSettingsListRequest { PageSize = 10, PageNumber = 1, CustomerUid = _customerUid, UserUid = _userUid, FilterName = "InvalidFilter", FilterValue = "Fuel" }).Result; } catch (AggregateException aggregateEx) { Assert.NotNull(aggregateEx.InnerException); var domainEx = (DomainException)aggregateEx.InnerException; Assert.NotNull(domainEx); Assert.NotNull(domainEx.Errors); Assert.True(domainEx.Errors.Any()); Assert.Equal(domainEx.Errors.First().ErrorCode, (int)ErrorCodes.InvalidFilterName); Assert.Equal(domainEx.Errors.First().Message, string.Format(UtilHelpers.GetEnumDescription(ErrorCodes.InvalidFilterName), "InvalidFilter")); } }
public async Task <IList <IErrorInfo> > Validate(IServiceRequest request) { if (!request.UserUid.HasValue) { return(new List <IErrorInfo> { base.GetValidationResult(ErrorCodes.UserUIDNull, UtilHelpers.GetEnumDescription(ErrorCodes.UserUIDNull), true, MethodInfo.GetCurrentMethod().Name) }); } return(null); }
public async Task <IList <IErrorInfo> > Validate(AssetSettingsListRequest request) { var result = new List <IErrorInfo>(); if (request.PageNumber <= 0) { result.Add(base.GetValidationResult(ErrorCodes.PageNumberLessThanOne, UtilHelpers.GetEnumDescription(ErrorCodes.PageNumberLessThanOne), true, MethodInfo.GetCurrentMethod().Name)); } if (request.PageSize <= 0) { result.Add(base.GetValidationResult(ErrorCodes.PageSizeLessThanOne, UtilHelpers.GetEnumDescription(ErrorCodes.PageSizeLessThanOne), true, MethodInfo.GetCurrentMethod().Name)); } return(result.Count > 0 ? result : null); }
public void Save_InvalidAssetUIDInAssetUIDs_ThrowsDomainException() { var request = new AssetSettingsRequest { AssetUIds = new List <string>(this._assetUIDs.Take(2).Select(x => x.ToString())), CustomerUid = this._customerUid, UserUid = this._userUid, TargetValues = new Dictionary <AssetTargetType, double?> { { AssetTargetType.BucketVolumeinCuMeter, 100 } } }; var invalidAssetUID = Guid.NewGuid().ToString(); request.AssetUIds.Add(invalidAssetUID); var result = this._assetSettingsService.Save(request).Result; Assert.Equal(result.Errors.Count, 1); Assert.Equal(result.Errors.First().ErrorCode, (int)ErrorCodes.InvalidAssetUID); Assert.Equal(result.Errors.First().Message, string.Format(UtilHelpers.GetEnumDescription(ErrorCodes.InvalidAssetUID), invalidAssetUID)); }
protected List <AssetErrorInfo> GetErrorLists(DomainException domainEx) { var errorLists = new List <AssetErrorInfo>(); if (domainEx.Errors == null) { domainEx.Errors = new List <ErrorInfo>(); } if (domainEx.Error != null) { errorLists.Add(new AssetErrorInfo { ErrorCode = (int)ExceptionErrorCodes.InvalidRequest, Message = UtilHelpers.GetEnumDescription(ExceptionErrorCodes.InvalidRequest) }); } foreach (var error in domainEx.Errors) { var assetError = error as AssetErrorInfo; if (assetError != null) { errorLists.Add(new AssetErrorInfo { AssetUID = assetError.AssetUID, ErrorCode = assetError.ErrorCode, Message = assetError.Message }); } else { errorLists.Add(new AssetErrorInfo { ErrorCode = error.ErrorCode, Message = error.Message }); } } return(errorLists); }
private Task HandleExceptionAsync(HttpContext context, Exception exception) { ExceptionResponse exceptionResponse; var jsonSerializationEx = exception as JsonSerializationException; var domainEx = exception as DomainException; context.Response.ContentType = "application/json"; _loggingService.Error("An Error has occurred : ", "ExceptionMiddleware.HandleExceptionAsync", exception); if (jsonSerializationEx != null && jsonSerializationEx.Message.Contains("Invalid Request")) { ExceptionErrorCodes errorCode = ExceptionErrorCodes.InvalidRequest; string message = UtilHelpers.GetEnumDescription(errorCode); context.Response.StatusCode = (int)HttpStatusCode.BadRequest; exceptionResponse = new ExceptionResponse(new AssetErrorInfo { ErrorCode = (int)errorCode, Message = string.Format(message, jsonSerializationEx.Message) }); } else if (domainEx != null) { context.Response.StatusCode = (int)HttpStatusCode.BadRequest; exceptionResponse = new ExceptionResponse(GetErrorLists(domainEx)); } else { context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; exceptionResponse = new ExceptionResponse(new AssetErrorInfo { Message = "An Unexpected Error has occurred", ErrorCode = (int)ExceptionErrorCodes.UnexpectedError }); } if (string.Compare(Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"), EnvironmentName.Development, StringComparison.OrdinalIgnoreCase) == 0) { exceptionResponse.Exception = exception; } return(context.Response.WriteAsync(JsonConvert.SerializeObject(exceptionResponse))); }
public async Task <IList <IErrorInfo> > Validate(IServiceRequest request) { if (!request.CustomerUid.HasValue) { return(new List <IErrorInfo> { base.GetValidationResult(ErrorCodes.CustomerUIDNull, UtilHelpers.GetEnumDescription(ErrorCodes.CustomerUIDNull), true, MethodInfo.GetCurrentMethod().Name) }); } else { var result = await _customerRepository.GetCustomerInfo(new List <Guid> { request.CustomerUid.Value }); if (result.Count() <= 0) { return(new List <IErrorInfo> { base.GetValidationResult(ErrorCodes.InvalidCustomerUID, UtilHelpers.GetEnumDescription(ErrorCodes.InvalidCustomerUID), true, MethodInfo.GetCurrentMethod().Name) }); } } return(null); }
public void Fetch_UserUIDNull_ThrowsDomainException() { var request = new AssetSettingsRequest { AssetUIds = new List <string>(this._assetUIDs.Select(x => x.ToString())), CustomerUid = this._customerUid, UserUid = null }; try { var result = this._assetSettingsService.Fetch(request).Result; } catch (AggregateException aggregateEx) { Assert.NotNull(aggregateEx.InnerException); var domainEx = (DomainException)aggregateEx.InnerException; Assert.NotNull(domainEx); Assert.NotNull(domainEx.Errors); Assert.Equal(domainEx.Errors.First().ErrorCode, (int)ErrorCodes.UserUIDNull); Assert.Equal(domainEx.Errors.First().Message, UtilHelpers.GetEnumDescription(ErrorCodes.UserUIDNull)); } }
public void FetchEssentialAssets_InvalidPageSize_ThrowsDomainException() { try { var response = _assetSettingsListService.FetchEssentialAssets(new AssetSettingsListRequest { PageSize = 0, PageNumber = 1, CustomerUid = _customerUid, UserUid = _userUid }).Result; } catch (AggregateException aggregateEx) { Assert.NotNull(aggregateEx.InnerException); var domainEx = (DomainException)aggregateEx.InnerException; Assert.NotNull(domainEx); Assert.NotNull(domainEx.Errors); Assert.True(domainEx.Errors.Any()); Assert.Equal(domainEx.Errors.First().ErrorCode, (int)ErrorCodes.PageSizeLessThanOne); Assert.Equal(domainEx.Errors.First().Message, UtilHelpers.GetEnumDescription(ErrorCodes.PageSizeLessThanOne)); } }
public async Task <IList <IErrorInfo> > Validate(AssetSettingsListRequest request) { var result = new List <IErrorInfo>(); if (!string.IsNullOrEmpty(request.FilterName)) { if (string.IsNullOrEmpty(request.FilterValue)) { result.Add(base.GetValidationResult(ErrorCodes.FilterValueNull, string.Format(UtilHelpers.GetEnumDescription(ErrorCodes.FilterValueNull)), true, MethodInfo.GetCurrentMethod().Name)); } if (!Enum.GetNames(typeof(AssetSettingsFilters)).Any(x => x.ToLower() == request.FilterName.ToLower())) { result.Add(base.GetValidationResult(ErrorCodes.InvalidFilterName, string.Format(UtilHelpers.GetEnumDescription(ErrorCodes.InvalidFilterName), request.FilterName), true, MethodInfo.GetCurrentMethod().Name)); } } else { if (!string.IsNullOrEmpty(request.FilterValue)) { result.Add(base.GetValidationResult(ErrorCodes.FilterNameNull, UtilHelpers.GetEnumDescription(ErrorCodes.FilterNameNull), true, MethodInfo.GetCurrentMethod().Name)); } } return(result.Count > 0 ? result : null); }
public async Task <IList <IErrorInfo> > Validate(AssetSettingsListRequest request) { var result = new List <IErrorInfo>(); if (!string.IsNullOrEmpty(request.SortColumn)) { var sortColumn = request.SortColumn.Replace("-", string.Empty); if (!Enum.GetNames(typeof(AssetSettingsSortColumns)).Any(x => x.ToLower() == sortColumn.ToLower())) { result.Add(base.GetValidationResult(ErrorCodes.InvalidSortColumn, string.Format(UtilHelpers.GetEnumDescription(ErrorCodes.InvalidSortColumn), sortColumn), true, MethodInfo.GetCurrentMethod().Name)); } } return(result.Count > 0 ? result : null); }
public async Task <IList <IErrorInfo> > Validate(AssetFuelBurnRateSettingRequest request) { if (request.WorkTargetValue >= 0 && request.IdleTargetValue > 0) { if (request.IdleTargetValue > request.WorkTargetValue) { return(new List <IErrorInfo> { base.GetValidationResult(ErrorCodes.WorkValueShouldBeLessThanIdleValue, UtilHelpers.GetEnumDescription(ErrorCodes.WorkValueShouldBeLessThanIdleValue), true, MethodInfo.GetCurrentMethod().Name) }); } } else if (request.WorkTargetValue < 0 && request.IdleTargetValue < 0) { return(new List <IErrorInfo> { base.GetValidationResult(ErrorCodes.WorkAndIdleValueShouldNotBeNegative, UtilHelpers.GetEnumDescription(ErrorCodes.WorkAndIdleValueShouldNotBeNegative), true, MethodInfo.GetCurrentMethod().Name) }); } else if (request.WorkTargetValue < 0) { return(new List <IErrorInfo> { base.GetValidationResult(ErrorCodes.WorkValueShouldNotBeNegative, UtilHelpers.GetEnumDescription(ErrorCodes.WorkValueShouldNotBeNegative), true, MethodInfo.GetCurrentMethod().Name) }); } else if (request.IdleTargetValue < 0) { return(new List <IErrorInfo> { base.GetValidationResult(ErrorCodes.IdleValueShouldNotBeNegative, UtilHelpers.GetEnumDescription(ErrorCodes.IdleValueShouldNotBeNegative), true, MethodInfo.GetCurrentMethod().Name) }); } return(null); }
public async Task <IList <IErrorInfo> > Validate(AssetSettingValidationRequestBase request) { var result = new List <IErrorInfo>(); var deviceTypeParameterAttributes = await this._parameterAttributeCache.Get(request.DeviceType, request.GroupName); if (deviceTypeParameterAttributes != null && deviceTypeParameterAttributes.Any(x => x.IncludeInd)) { var subscriptionPlans = await _subscriptionServicePlanRepository.FetchSubscription(request.AssetUIDs, DateTime.Now.ToDateTimeStringWithYearMonthDayFormat()); foreach (var parameter in deviceTypeParameterAttributes.Where(x => x.IncludeInd).GroupBy(x => x.ParameterName)) { var serviceTypeParameters = await this._serviceTypeParameterCache.Get(parameter.Key); foreach (var serviceTypeParameter in serviceTypeParameters) { if (subscriptionPlans.ContainsKey(serviceTypeParameter.ServiceTypeID)) { if (serviceTypeParameter.IncludeInd) { var subscriptionNotAvailableAssets = request.AssetUIDs.Except(subscriptionPlans[serviceTypeParameter.ServiceTypeID].Select(x => x.AssetUID.ToString())); if (subscriptionNotAvailableAssets.Any()) { result.AddRange(base.GetValidationResults(ErrorCodes.AssetSubscriptionIsInvalid, subscriptionNotAvailableAssets, string.Format(UtilHelpers.GetEnumDescription(ErrorCodes.AssetSubscriptionIsInvalid), serviceTypeParameter.DeviceParamGroupName + "\\" + serviceTypeParameter.DeviceParameterName), true, "SubscriptionValidator.Validate")); request.AssetUIDs.RemoveAll(subscriptionNotAvailableAssets.Contains); } } else { var subscriptionShouldNotBeAvailableAssets = request.AssetUIDs.Intersect(subscriptionPlans[serviceTypeParameter.ServiceTypeID].Select(x => x.AssetUID.ToString())); if (subscriptionShouldNotBeAvailableAssets.Any()) { result.AddRange(base.GetValidationResults(ErrorCodes.AssetSubscriptionIsInvalid, subscriptionShouldNotBeAvailableAssets, string.Format(UtilHelpers.GetEnumDescription(ErrorCodes.AssetSubscriptionIsInvalid), serviceTypeParameter.DeviceParamGroupName + "\\" + serviceTypeParameter.DeviceParameterName), true, "SubscriptionValidator.Validate")); request.AssetUIDs.RemoveAll(subscriptionShouldNotBeAvailableAssets.Contains); } } } } } } return(result); }
public async Task <IList <IErrorInfo> > Validate(AssetSettingsRequestBase request) { if (request.TargetValues != null && request.TargetValues.Keys.Count == 1) { foreach (var targetValue in request.TargetValues) { if (targetValue.Value < 0) { return(new List <IErrorInfo> { base.GetValidationResult(ErrorCodes.TargetValueIsNegative, UtilHelpers.GetEnumDescription(ErrorCodes.TargetValueIsNegative), true, MethodInfo.GetCurrentMethod().Name) }); } } } return(null); }
public async Task <IList <IErrorInfo> > Validate(AssetFuelBurnRateSettingRequest request) { var assetsSettingsResponse = await _assetSettingsRepository.FetchAssetConfig(request.AssetUIds, new AssetSettingsDto { StartDate = request.StartDate, TargetValues = AssignAssetTargetValues(request.TargetValues, new AssetSettingsDto()), FilterCriteria = new List <KeyValuePair <string, Tuple <string, object> > > { new KeyValuePair <string, Tuple <string, object> >("<=", new Tuple <string, object>("AC.StartDate", request.StartDate.ToDateTimeStringWithYearMonthDayFormat())), new KeyValuePair <string, Tuple <string, object> >("is", new Tuple <string, object>("AC.EndDate", null)) } }); if (assetsSettingsResponse?.Count() == 0) { if (!(request.WorkTargetValue.HasValue && request.IdleTargetValue.HasValue)) { return(new List <IErrorInfo> { GetValidationResult(ErrorCodes.WorkOrIdleValuesShouldNotBeNull, UtilHelpers.GetEnumDescription(ErrorCodes.WorkOrIdleValuesShouldNotBeNull), true, MethodBase.GetCurrentMethod().Name) }); } } else if (request.WorkTargetValue.HasValue != request.IdleTargetValue.HasValue) { return(new List <IErrorInfo> { GetValidationResult(ErrorCodes.BothWorkAndIdleValuesShouldBeNullORShouldNotBeNull, UtilHelpers.GetEnumDescription(ErrorCodes.BothWorkAndIdleValuesShouldBeNullORShouldNotBeNull), true, MethodInfo.GetCurrentMethod().Name) }); } return(null); }