public IActionResult Load(long?ID, long?LineOfBusiness, long?BasicLine, long?langId) { GetSubBusniess operation = new GetSubBusniess(); operation.ID = ID; operation.BasicLineOfBusniess = BasicLine; operation.LineOfBusniess = LineOfBusiness; if (langId.HasValue) { operation.LangID = langId; } else { operation.LangID = 1; } var result = operation.QueryAsync().Result; if (result is ValidationsOutput) { return(Ok(new ApiResult <List <ValidationItem> >() { Data = ((ValidationsOutput)result).Errors })); } else { return(Ok((List <SubLineOfBusnies>)result)); } }
public IActionResult LoadRelatedProduct(long?langId, long?productID) { GetProductsDetails operation = new GetProductsDetails(); GetSubBusniess subBusniess = new GetSubBusniess(); operation.ProductID = productID; if (langId.HasValue) { operation.LangID = langId; subBusniess.LangID = langId; } else { operation.LangID = 1; subBusniess.LangID = 1; } var result = operation.QueryAsync().Result; var sub = subBusniess.QueryAsync().Result; var ProductDetails = (List <ProductDetails>)result; var SubLineOfBusiness = (List <SubLineOfBusnies>)sub; List <SubLineOfBusnies> RelatedSubLine = new List <SubLineOfBusnies>(); List <SubLineOfBusnies> UnSubLine = new List <SubLineOfBusnies>(); if (ProductDetails.Count > 0) { foreach (var prod in ProductDetails) { foreach (var item in SubLineOfBusiness) { if (prod.SubLineOfBusniess == item.ID) { bool alreadyExist = RelatedSubLine.Contains(item); bool alreadyExistInSecondList = UnSubLine.Contains(item); if (!alreadyExist && !alreadyExistInSecondList) { RelatedSubLine.Add(item); } else { RelatedSubLine.Add(item); UnSubLine.Remove(item); } } else { bool alreadyExist = RelatedSubLine.Contains(item); bool alreadyExistInFirstList = UnSubLine.Contains(item); if (!alreadyExist && !alreadyExistInFirstList) { UnSubLine.Add(item); } } } } } else { UnSubLine = SubLineOfBusiness; } if (result is ValidationsOutput) { return(Ok(new ApiResult <List <ValidationItem> >() { Data = ((ValidationsOutput)result).Errors })); } else { return(Ok(new { RelatedSubLines = RelatedSubLine, UnRelatedSubLines = UnSubLine })); } }