public async Task <CommonResponse> SubmitAnalyzedSample(AnalyserSampleRequest values, int userId) { using (var uow = this.unitOfWorkFactory.GetUnitOfWork()) { var productSupplierEntity = await uow.Repository <SupplierProduct>().Query().Select().SingleOrDefaultAsync(t => t.Id == values.ProductSupplierId); if (productSupplierEntity == null) { return(CommonResponse.CreateError("Error", "Err02", "Product not found")); } var productAnalyzer = new ProductAnalyzer { AnalyzerId = userId, SupplilerProductId = values.ProductSupplierId ?? 1, AnalyzedComposition = values.AnalysedComposition ?? 1, IsDealPlaced = "y" }; uow.Repository <ProductAnalyzer>().Add(productAnalyzer); productSupplierEntity.Composition -= productAnalyzer.AnalyzedComposition; var response = uow.SaveChanges(); if (response.Response.status == false) { return(CommonResponse.CreateError("Error occured while adding analysing composition.", "ERR001", "")); } return(CommonResponse.CreateSuccess("Success", "SUC001", "")); } }
public async Task <HttpResponseMessage> SubmitAnalysis(AnalyserSampleRequest values) { var info = await customerInfo(); return(Request.CreateResponse(HttpStatusCode.OK, await this.AnalyzerService.SubmitAnalyzedSample(values, info.UserId))); }