public ActionResult <ApiResponse <CustomerProductResponse> > Post([FromBody] CustomerProductCreateRequest request) { ServicePrimitiveResponse insertCustomerProductResult = new ServicePrimitiveResponse(); //Fluent Validation Controls CustomerProductValidator validator = new CustomerProductValidator(); ValidationResult results = validator.Validate(request); if (results.IsValid) { //Check IdentificationNo IsExist bool isExistCustomer = _customerRepository.FindFirstBy(p => p.IdentificationNumber.Equals(request.IdentificationNumber)).ResponseCode == (int)EntityResponseCodes.NoRecordFound; if (isExistCustomer) { return(BadRequest(new ApiResponse { Code = (int)ApiResponseCodes.ValidationError, ErrorMessage = "Identification Number Is Not Exist!" })); } //Check ProductId IsExist bool isExistProduct = _productRepository.Find(request.ProductId).ResponseCode == (int)EntityResponseCodes.NoRecordFound; if (isExistProduct) { return(BadRequest(new ApiResponse { Code = (int)ApiResponseCodes.ValidationError, ErrorMessage = "Product Id Is Not Exist!" })); } insertCustomerProductResult = _customerProductRepository.InsertCustomerProduct(request.IdentificationNumber, request.ProductId); if (insertCustomerProductResult.ResponseCode == (int)EntityResponseCodes.Successfull) { return(Get(request.IdentificationNumber)); //If Success Call Get ProductInfo endpoint } } else { return(BadRequest(GetValidationErrors(results))); } throw new ApiException((int)ApiResponseCodes.DbError, insertCustomerProductResult.ResponseMessage); }