public ActionResult Picker(string AnswerColor) { using (var context = new BearQuizContext()) { var model = context.Beanies.Where(b => b.Image != "" && string.IsNullOrEmpty(b.Color) && !b.Image.EndsWith("soon.jpg")).OrderBy(b => b.Name).FirstOrDefault(); model.Color = AnswerColor; context.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Match(Quiz answers) { using (var db = new BearQuizContext()) { var answer = db.Beanies.Where(b => string.Equals(b.Color, answers.color)). Where(b => string.Equals(b.Country, answers.country) || string.IsNullOrEmpty(b.Country)) .Where(b => string.Equals(b.Animal, answers.animal)).First(); return(View(answer)); } }
public ActionResult Index() { using (var db = new BearQuizContext()) { var model = db.Beanies.Where(b => b.Image != "" && string.IsNullOrEmpty(b.Color) && !b.Image.EndsWith("soon.jpg")).OrderBy(b => b.Name).FirstOrDefault(); if (model == null) { return(RedirectToAction("Index", "Home")); } return(View(model)); } }