private void GetQuoteCompaniesByQuoteId(List <DeltoneCRM_DAL.QuoteDAL.QuoteAssignOne> objLst, int companyId, int repId, DateTime allocTime) { var listQuotesByCOmpaies = new List <DeltoneCRM_DAL.QuoteDAL.QuoteAssignOne>(); listQuotesByCOmpaies = (from lis in objLst where lis.CompanyId == companyId select lis).ToList(); if (listQuotesByCOmpaies.Count() > 0) { string CONNSTRING = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString; var currentDate = DateTime.Now; var comDal = new QuoteDAL(CONNSTRING); Random rnd = new Random(); var listQuotesAllocate = comDal.GetAssignQuotes(); for (var i = 0; i < listQuotesByCOmpaies.Count(); i++) { if (listQuotesAllocate.Any(x => x.QuoteId == listQuotesByCOmpaies[i].QuoteId && x.ExpiryDate.Date > currentDate.Date)) { } else { comDal.InsertQuoteAllocate(listQuotesByCOmpaies[i].QuoteId, repId, currentDate, allocTime); } } } }
private DeltoneCRM_DAL.QuoteDAL.QuoteAssignOne GetNewRecentQuote(List <DeltoneCRM_DAL.QuoteDAL.QuoteAssignOne> coViewAll, int repId) { var comDal = new QuoteDAL(CONNSTRING); var listQuotesAllocate = comDal.GetAssignQuotes(); Random rnd = new Random(); var currentDate = DateTime.Now; var pickedCom = coViewAll.OrderBy(x => rnd.Next()).Take(1).ToList(); if (pickedCom.Count > 0) { var pickedObj = pickedCom[0]; if (listQuotesAllocate.Any(x => x.QuoteId == pickedObj.QuoteId && x.ExpiryDate.Date > currentDate.Date)) { return(GetNewRecentQuote(coViewAll, repId)); } else if (listQuotesAllocate.Any(x => x.QuoteId == pickedObj.QuoteId && x.UserId == repId)) { return(GetNewRecentQuote(coViewAll, repId)); } else { return(pickedObj); } } return(null); }
private DeltoneCRM_DAL.QuoteDAL.QuoteAssignOne GetNewRecentQuote(List <DeltoneCRM_DAL.QuoteDAL.QuoteAssignOne> coViewAll, int repId) { string CONNSTRING = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString; var comDal = new QuoteDAL(CONNSTRING); var listQuotesAllocate = comDal.GetAssignQuotes(); Random rnd = new Random(); var currentDate = DateTime.Now; var pickedCom = coViewAll.OrderBy(x => rnd.Next()).Take(1).ToList(); if (pickedCom.Count > 0) { var pickedObj = pickedCom[0]; if (listQuotesAllocate.Any(x => x.QuoteId == pickedObj.QuoteId && x.ExpiryDate.Date > currentDate.Date)) { return(GetNewRecentQuote(coViewAll, repId)); } //else // if (listCompanylead.Any(x => x.CompanyId == pickedObj.CompanyID // && x.UserId == repId)) // { // return GetNewCompaySel(coViewAll, repId); // } else { return(pickedObj); } } return(null); }