Пример #1
0
        public ActionResult IdentifyMushrooms(string Id)
        {
            FungeyeDAL DAL = new FungeyeDAL();

            ViewBag.CapChars  = DAL.GetAllMushrooms().Select(x => x.CapChar).Distinct().ToList();
            ViewBag.CapColors = DAL.GetAllMushrooms().Select(x => x.CapColor).Distinct().ToList();
            ViewBag.Stems     = DAL.GetAllMushrooms().Select(x => x.Stem).Distinct().ToList();
            ViewBag.Edibility = DAL.GetAllMushrooms().Select(x => x.Edibility).Distinct().ToList();

            ViewBag.User      = DAL.GetUser(Id);
            ViewBag.Mushrooms = DAL.GetAllMushrooms();

            return(View());
        }
Пример #2
0
        public ContentResult FilterResults(string capChar, string capColor, string stem, string edibility)
        {
            FungeyeDAL DAL = new FungeyeDAL();

            List <Mushroom> results = DAL.GetAllMushrooms();

            if (!string.IsNullOrEmpty(capChar) && capChar != "null")
            {
                results = results.Where(x => x.CapChar.ToLower() == capChar.ToLower()).ToList();
            }

            if (!string.IsNullOrEmpty(capColor) && capColor != "null")
            {
                results = results.Where(x => x.CapColor.ToLower() == capColor.ToLower()).ToList();
            }

            if (!string.IsNullOrEmpty(stem) && stem != "null")
            {
                results = results.Where(x => x.Stem.ToLower() == stem.ToLower()).ToList();
            }

            if (!string.IsNullOrEmpty(edibility) && edibility != "null")
            {
                results = results.Where(x => x.Edibility.ToLower() == edibility.ToLower()).ToList();
            }

            var list = JsonConvert.SerializeObject(results,
                                                   Formatting.None,
                                                   new JsonSerializerSettings()
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            });

            return(Content(list, "application/json"));
        }