コード例 #1
0
 public ActionResult NoteDetail(int id, Notedetailmodal notedetailmodal)
 {
     projectEntities1 db   = new projectEntities1();
     NoteDetail       data = db.NoteDetails.Where(u => u.Id == id).FirstOrDefault();
     {
         return(View(data));
     }
 }
コード例 #2
0
        public ActionResult SearchNotes(string searchn, string country, string type, string category, string university, string course)
        {
            NoteDetail       nm = new NoteDetail();
            Notedetailmodal  sn = new Notedetailmodal();
            projectEntities1 db = new projectEntities1();

            ViewData["Category"]   = db.Categories.ToList <Category>();
            ViewData["Type"]       = db.Types.ToList();
            ViewData["Country"]    = db.Countries.ToList();
            ViewData["Rate"]       = db.Ratings.ToList();
            ViewData["Course"]     = db.NoteDetails.ToList();
            ViewData["University"] = db.NoteDetails.ToList();

            List <NoteDetail> notes = db.NoteDetails.ToList();

            if (!string.IsNullOrEmpty(searchn))
            {
                notes = notes.Where(e => e.NoteTitle.ToLower().Contains(searchn.ToLower())).ToList();
            }
            if (country != "Select country" && !string.IsNullOrEmpty(country))
            {
                notes = notes.Where(e => e.Country != null && e.Country.ToLower().Contains(country.ToLower())).ToList();
            }
            if (type != "Select Type" && !string.IsNullOrEmpty(type))
            {
                notes = notes.Where(e => e.Type != null && e.Type.ToLower().Contains(type.ToLower())).ToList();
            }

            if (category != "Select category" && !string.IsNullOrEmpty(category))
            {
                notes = notes.Where(e => e.Category != null && e.Category.ToLower().Contains(category.ToLower())).ToList();
            }

            if (university != "Select University" && !string.IsNullOrEmpty(university))
            {
                notes = notes.Where(e => e.University != null && e.University.ToLower().Contains(university.ToLower())).ToList();
            }

            if (course != "Select Course" && !string.IsNullOrEmpty(course))
            {
                notes = notes.Where(e => e.Course != null && e.Course.ToLower().Contains(course.ToLower())).ToList();
            }



            return(View(notes));
        }