public async Task <CostingGetRes> GetCostingDetailsByQRFID(CostingGetReq request) { //var builder = Builders<mQRFPrice>.Filter; //var filter = builder.Where(q => q.QRFID == request.QRFID && q.IsCurrentVersion == true); //return await _MongoContext.mQRFPrice.Find(filter).Project(q => new CostingGetProperties //{ // QRFID = q.QRFID, // VersionId = q.VersionId, // VersionName = q.VersionName, // VersionDescription = q.VersionDescription, // IsCurrentVersion = q.IsCurrentVersion, // SalesOfficer = q.SalesOfficer, // CostingOfficer = q.CostingOfficer, // ProductAccountant = q.ProductAccountant, // AgentInfo = q.AgentInfo, // AgentProductInfo = q.AgentProductInfo, // AgentPassengerInfo = q.AgentPassengerInfo, // AgentRoom = q.QRFAgentRoom, // DepartureDates = q.Departures, //}).FirstOrDefaultAsync(); CostingGetRes response = new CostingGetRes(); var qrfprice = _MongoContext.mQRFPrice.AsQueryable().Where(x => x.QRFID == request.QRFID && x.IsCurrentVersion == true).OrderByDescending(y => y.VersionId).FirstOrDefault(); response.CostingGetProperties.QRFID = qrfprice.QRFID; response.CostingGetProperties.QRFPriceID = qrfprice.QRFPrice_Id; response.CostingGetProperties.VersionId = qrfprice.VersionId; response.CostingGetProperties.VersionName = qrfprice.VersionName; response.CostingGetProperties.VersionDescription = qrfprice.VersionDescription; response.CostingGetProperties.IsCurrentVersion = qrfprice.IsCurrentVersion; response.CostingGetProperties.SalesOfficer = qrfprice.SalesOfficer; response.CostingGetProperties.CostingOfficer = qrfprice.CostingOfficer; response.CostingGetProperties.ProductAccountant = qrfprice.ProductAccountant; response.CostingGetProperties.ValidForAcceptance = qrfprice.ValidForAcceptance; response.CostingGetProperties.ValidForTravel = qrfprice.ValidForTravel; response.CostingGetProperties.AgentInfo = qrfprice.AgentInfo; response.CostingGetProperties.AgentProductInfo = qrfprice.AgentProductInfo; response.CostingGetProperties.AgentPassengerInfo = qrfprice.AgentPassengerInfo; response.CostingGetProperties.AgentRoom = qrfprice.QRFAgentRoom; response.CostingGetProperties.DepartureDates = qrfprice.Departures; response.CostingGetProperties.FollowUpCostingOfficer = qrfprice.FollowUpCostingOfficer; response.CostingGetProperties.FollowUpWithClient = qrfprice.FollowUpWithClient; ContactDetailsResponse objContactDetailsRes = _userRepository.GetContactsByEmailId(new ContactDetailsRequest { Email = qrfprice.SalesOfficer }); if (objContactDetailsRes != null && objContactDetailsRes.Contacts != null) { response.CostingGetProperties.SalesOfficerMobile = !string.IsNullOrEmpty(objContactDetailsRes.Contacts.MOBILE) ? objContactDetailsRes.Contacts.MOBILE : objContactDetailsRes.Contacts.TEL; } response.EnquiryPipeline = _MongoContext.mQuote.AsQueryable().Where(x => x.QRFID == request.QRFID).Select(y => y.CurrentPipeline).FirstOrDefault(); bool IsLinkedQRFsExist = _quoteRepository.ChcekLinkedQRFsExist(request.QRFID).Result; response.IsLinkedQRFsExist = IsLinkedQRFsExist; return(response); }