// Full summary of Quote/Property/Location public ActionResult QuoteSummary(int?quoteId) { if (!quoteId.HasValue) { try { quoteId = (int)Session["quoteId"]; } catch { // TODO: redirect return(RedirectToAction("GetStarted", "Quotes")); } } else { Session["quoteId"] = quoteId; } // TODO: do we have a User? using (IQuotesEntity qe = QuoteSource.CreateQuotesEntity()) { Quote q = qe.IncludeInQuotes("Property.Location.Homeowner.User").Where(qq => qq.Id == quoteId).FirstOrDefault(); return(View(q)); } }
public ActionResult QuoteDetails() { User user = Session["User"] as User; List <Quote> quoteList = new List <Quote>(); using (IQuotesEntity qe = QuoteSource.CreateQuotesEntity()) { quoteList.AddRange(qe.IncludeInQuotes("Property.Location.Homeowner.User") .Where(q => q.Property.Location.Homeowner.UserId == user.Id)); return(View(quoteList)); } }
public ActionResult QuoteDetails() { User user = Session["User"] as User; List <Quote> quoteList = new List <Quote>(); //List<Policy> policyList = new List<Policy>(); using (IQuotesEntity qe = QuoteSource.CreateQuotesEntity()) { Homeowner ho = qe.Homeowners.FirstOrDefault(h => h.UserId == user.Id); quoteList.AddRange(qe.IncludeInQuotes("Property.Location.Homeowner.User") .Where(q => q.Property.Location.Homeowner.UserId == user.Id)); //policyList.AddRange(qe.IncludeInPolicies("Quote.Property.Location.Homeowner.User") // .Where(p => p.Quote.Property.Location.Homeowner.UserId == ho.UserId)); //var quotesWithPolicy = quoteList.Where(q => policyList.Any(p => p.QuoteId == q.Id)); //var quotesWithoutPolicy = quoteList.Except(quotesWithPolicy); return(View(quoteList)); //return View(quotesWithoutPolicy); } }
// Full summary of Quote/Property/Location public ActionResult QuoteSummary(int?quoteId) { if (!quoteId.HasValue) { try { quoteId = (int)Session["quoteId"]; } catch { // TODO: redirect return(RedirectToAction("GetStarted", "Quotes")); } } else { Session["quoteId"] = quoteId; } // TODO: do we have a User? using (IQuotesEntity qe = QuoteSource.CreateQuotesEntity()) { Quote q = qe.IncludeInQuotes("Property.Location.Homeowner.User").Where(qq => qq.Id == quoteId).FirstOrDefault(); // TODO: is q null? //Added this section in order to stop the user from being able to buy same quote multiple times List <Policy> policies = new List <Policy>(); User user = Session["User"] as User; Homeowner ho = qe.Homeowners.FirstOrDefault(h => h.UserId == user.Id); policies.AddRange(qe.IncludeInPolicies("Quote.Property.Location.Homeowner.User") .Where(p => p.Quote.Property.Location.Homeowner.UserId == ho.UserId && p.QuoteId == q.Id)); bool isPolicyExist = policies.Count > 0; Tuple <Quote, bool> returningParameters = new Tuple <Quote, bool>(q, isPolicyExist); //Tuple used for multiple returns return(View(returningParameters)); //return View(q); This not needed anymore, q returned in line 55 via Tuple } }