public ActionResult AddFiles(Files model, string submit) { if (submit == "Thêm") { if (model != null) { model.Name = model.Name.ToString().Trim() ?? ""; model.FileForm = model.FileForm; db.Files.Add(model); db.SaveChanges(); } SetAlert("Thêm thông tin thành công! :D", "success"); return(RedirectToAction("Index")); } else if (submit == "Cập Nhật") { if (model != null) { var list = db.Files.SingleOrDefault(x => x.ID == model.ID); list.Name = model.Name; list.FileForm = model.FileForm.ToString(); db.SaveChanges(); model = null; } SetAlert("Cập nhật mẫu báo cáo thành công! :D", "success"); return(RedirectToAction("Index")); } else { List <Files> list = GetData().OrderBy(s => s.Name).ToList(); return(View("Index", list)); } }
public ActionResult Add(Menu model, string submit) { if (submit == "Thêm") { isThemMoi = true; if (model != null) { model.Name = model.Name.ToString().Trim(); model.Description = model.Description.ToString().Trim(); model.MenuUrl = model.MenuUrl.ToString().Trim(); model.MenuICon = model.MenuICon.ToString().Trim(); model.Enable = model.Enable; model.CreatedDate = model.CreatedDate.GetValueOrDefault(System.DateTime.Now); db.Menu.Add(model); db.SaveChanges(); model = null; } return(RedirectToAction("Index")); } else if (submit == "Cập Nhật") { isThemMoi = false; if (model != null) { var list = db.Menu.SingleOrDefault(x => x.ID == model.ID); list.Name = model.Name.ToString().Trim(); list.Description = model.Description.ToString(); list.MenuUrl = model.MenuUrl.ToString().Trim(); list.MenuICon = model.MenuICon.ToString().Trim(); list.Enable = model.Enable; list.ModifiedDate = model.CreatedDate.GetValueOrDefault(System.DateTime.Now); db.SaveChanges(); model = null; } return(RedirectToAction("Index")); } else if (submit == "Tìm") { if (!string.IsNullOrEmpty(model.Name)) { List <Menu> list = GetData().Where(s => s.Name.Contains(model.Name)).ToList(); return(View("Index", list)); } else { List <Menu> list = GetData(); return(View("Index", list)); } } else { List <Menu> list = GetData().OrderBy(s => s.Name).ToList(); return(View("Index", list)); } }
public ActionResult Add(Class model, string submit) { if (submit == "Thêm") { isThemMoi = true; if (model != null) { model.Name = model.Name.ToString(); model.Address = model.Address.ToString(); model.TeacherID = model.TeacherID; model.ScienceID = model.ScienceID; model.CreatedDate = model.CreatedDate.GetValueOrDefault(System.DateTime.Now); db.Class.Add(model); db.SaveChanges(); model = null; } SetAlert("Thêm thông tin thành công! :D", "success"); return(RedirectToAction("Index")); } else if (submit == "Cập Nhật") { isThemMoi = false; if (model != null) { var list = db.Class.SingleOrDefault(x => x.ID == model.ID); list.Name = model.Name; list.Address = model.Address.ToString(); list.TeacherID = model.TeacherID; list.ScienceID = model.ScienceID; list.ModifiedDate = model.CreatedDate.GetValueOrDefault(System.DateTime.Now); db.SaveChanges(); } SetAlert("Cập nhật thông tin thành công! :D", "success"); return(RedirectToAction("Index")); } else if (submit == "Tìm") { if (!string.IsNullOrEmpty(model.Name)) { List <Class> list = GetData().Where(s => s.Name.Contains(model.Name)).ToList(); return(View("Index", list)); } else { List <Class> list = GetData(); return(View("Index", list)); } } else { List <Class> list = GetData().OrderBy(s => s.Name).ToList(); return(View("Index", list)); } }
/// <returns></returns> public ActionResult Notification() { var userLogin = (UserLogin)Session[Managing_Teacher_Work.Common.CommonConstants.USER_SESSION]; var notifications = db.Notification.Where(x => x.UserID == userLogin.ID); foreach (var item in notifications) { item.IsRead = true; } db.SaveChanges(); ViewBag.userLogin = userLogin; return View(notifications.ToList()); }
public bool Delete(int id) { try { var user = db.Files.Find(id); db.Files.Remove(user); db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public static void StartService(object sender, ElapsedEventArgs e) { if (_timer != null) { _timer.Stop(); } try { lock (_locker) { // service chuyen ve khong hoat dong var checks1 = db.CalendarWorking.Where(x => x.Status.Equals("HoatDong")).ToList() .Where(x => x.DateEnd.Date < DateTime.Now.Date); if (checks1.Count() > 0) { foreach (var item in checks1) { var check = db.CalendarWorking.Find(item.ID); check.Status = "KhongHoatDong"; db.SaveChanges(); } } // service chuyen ve khong hoan thanh va khong hoat dong var checks2 = db.CalendarWorking.Where(x => x.WorkState.Equals("DangThucHien") || x.WorkState.Equals("ChuaHoanThanh") || x.WorkState.Equals("DangDiemDanh") ).ToList() .Where(x => x.DateEnd.Date < DateTime.Now.Date); if (checks2.Count() > 0) { foreach (var item in checks2) { var check = db.CalendarWorking.Find(item.ID); check.WorkState = "KhongHoanThanh"; db.SaveChanges(); } } } } catch (Exception ex) { } if (_timer != null) { _timer.Start(); } }
//public ActionResult getList(int id) //{ // JsonSerializerSettings jss = new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }; // var hs = db.GroupUser.SingleOrDefault(x => x.ID == id); // var result = JsonConvert.SerializeObject(hs, Formatting.Indented, jss); // return this.Json(result, JsonRequestBehavior.AllowGet); //} public ActionResult Add(GroupUser model, string submit) { if (submit == "Thêm") { isThemMoi = true; if (model != null) { model.Name_GroupUser = model.Name_GroupUser.ToString().Trim(); db.GroupUser.Add(model); db.SaveChanges(); model = null; } return(RedirectToAction("Index")); } else if (submit == "Cập Nhật") { isThemMoi = false; if (model != null) { var list = db.GroupUser.SingleOrDefault(x => x.ID == model.ID); list.Name_GroupUser = model.Name_GroupUser.ToString().Trim(); db.SaveChanges(); model = null; } return(RedirectToAction("Index")); } else if (submit == "Tìm") { if (!string.IsNullOrEmpty(model.Name_GroupUser)) { List <GroupUser> list = GetData().Where(s => s.Name_GroupUser.Contains(model.Name_GroupUser)).ToList(); return(View("Index", list)); } else { List <GroupUser> list = GetData(); return(View("Index", list)); } } else { List <GroupUser> list = GetData().OrderBy(s => s.Name_GroupUser).ToList(); return(View("Index", list)); } }
protected void SetNotification() { try { var _userLogin = (UserLogin)Session[Common.CommonConstants.USER_SESSION]; if (_userLogin != null) { if (_userLogin.GroupID == "MEMBER") { MTWDbContext db = new MTWDbContext(); var dateNow = DateTime.Now; var teacher = db.Teacher.Find(_userLogin.TeacherID); var calendarWorkingTeachers = db.CalendarWorkingTeacher.Where(x => x.TeacherID == teacher.ID).Select(x => x.CalendarWorkingID).ToArray(); var calendarWorking = db.CalendarWorking.OrderBy(x => x.DateStart).ToList().FirstOrDefault(x => calendarWorkingTeachers.Contains(x.ID) && x.DateStart.Date > dateNow.Date ); var check = db.Notification.SingleOrDefault(x => x.ContentID == calendarWorking.ID); if (check == null) { db.Notification.Add(new Notification { Type = 0, ContentID = calendarWorking.ID, UserID = _userLogin.ID, IsRead = false, CreatedDate = dateNow, Contents = string.Format("Sắp đến công tác '{0}' vào thời gian '{1}' tại địa điểm '{2}'", calendarWorking.Name_CalendarWorking, calendarWorking.DateStart, calendarWorking.Address) }); db.SaveChanges(); } } } } catch { } }
public ActionResult Add(Work model, string submit) { if (submit == "Thêm") { isThemMoi = true; if (model != null) { model.Name_Work = model.Name_Work.ToString(); model.Description_Work = model.Description_Work.ToString(); model.Details_Work = model.Details_Work.ToString(); model.DateWorkStart = model.DateWorkStart; model.DateWorkEnd = model.DateWorkEnd; model.Note = model.Note.ToString(); model.Status = model.Status; model.CreatedDate = model.CreatedDate.GetValueOrDefault(System.DateTime.Now); db.Work.Add(model); db.SaveChanges(); model = null; } return(RedirectToAction("Index")); } else if (submit == "Cập Nhật") { isThemMoi = false; if (model != null) { var list = db.Work.SingleOrDefault(x => x.ID == model.ID); list.Name_Work = model.Name_Work ?? ""; list.Description_Work = model.Description_Work.ToString() ?? ""; list.Details_Work = model.Details_Work.ToString() ?? ""; list.DateWorkStart = model.DateWorkStart; list.DateWorkEnd = model.DateWorkEnd; list.Note = model.Note.ToString() ?? ""; list.Status = model.Status; list.ModifiedDate = model.CreatedDate.GetValueOrDefault(System.DateTime.Now); db.SaveChanges(); model = null; } return(RedirectToAction("Index")); } else if (submit == "Tìm") { if (!string.IsNullOrEmpty(model.Name_Work)) { List <Work> list = GetData().Where(s => s.Name_Work.Contains(model.Name_Work)).ToList(); return(View("Index", list)); } else { List <Work> list = GetData(); return(View("Index", list)); } } else { List <Work> list = GetData().OrderBy(s => s.Name_Work).ToList(); return(View("Index", list)); } }
public ActionResult Add(User model, string submit) { if (submit == "Thêm") { isThemMoi = true; if (model != null) { model.Name = model.Name.ToString().Trim(); model.UserName = model.UserName.ToString().Trim(); model.Password = Encryptor.MD5Hash(model.Password.Trim()); model.GroupID = model.GroupID; model.Status = model.Status; model.Phone = model.Phone.ToString().Trim(); model.Email = model.Email.ToString().Trim(); model.CreatedDate = model.CreatedDate.GetValueOrDefault(System.DateTime.Now); db.User.Add(model); db.SaveChanges(); model = null; } SetAlert("Thêm thông tin thành công! :D", "success"); return(RedirectToAction("Index")); } else if (submit == "Cập Nhật") { isThemMoi = false; if (model != null) { var list = db.User.SingleOrDefault(x => x.ID == model.ID); list.Name = model.Name.ToString().Trim(); list.UserName = model.UserName.ToString().Trim(); list.Password = Encryptor.MD5Hash(model.Password.Trim()); list.GroupID = model.GroupID; list.Status = model.Status; list.Phone = model.Phone.ToString().Trim(); list.Email = model.Email.ToString().Trim(); list.ModifiedDate = model.CreatedDate.GetValueOrDefault(System.DateTime.Now); db.SaveChanges(); model = null; } SetAlert("Cập nhật thông tin thành công! :D", "success"); return(RedirectToAction("Index")); } else if (submit == "Tìm") { if (!string.IsNullOrEmpty(model.UserName)) { List <User> list = GetData().Where(s => s.UserName.Contains(model.UserName)).ToList(); return(View("Index", list)); } else { List <User> list = GetData(); return(View("Index", list)); } } else { List <User> list = GetData().OrderBy(s => s.UserName).ToList(); return(View("Index", list)); } }
public ActionResult Add(Teacher model, string submit) { if (submit == "Thêm") { isThemMoi = true; if (model != null) { model.Name_Teacher = model.Name_Teacher.ToString().Trim(); model.Phone = model.Phone.Trim(); if (model.Address != null) { model.Address = model.Address.ToString().Trim(); } model.DateOfBirth = model.DateOfBirth; model.Avatar = model.Avatar.ToString().Trim(); model.Gender = model.Gender.ToString().Trim(); model.CreatedDate = model.CreatedDate.GetValueOrDefault(System.DateTime.Now); model.Status = model.Status.ToString(); model.SicenceID = model.SicenceID; db.Teacher.Add(model); db.SaveChanges(); model = null; } ViewBag.checkThemMoi = isThemMoi; SetAlert("Thêm thông tin thành công! :D", "success"); return(RedirectToAction("Index")); } else if (submit == "Cập Nhật") { isThemMoi = false; if (model != null) { var list = db.Teacher.SingleOrDefault(x => x.ID == model.ID); list.Name_Teacher = model.Name_Teacher.ToString().Trim(); list.Phone = model.Phone.Trim(); if (model.Address != null) { list.Address = model.Address.ToString().Trim(); } list.DateOfBirth = model.DateOfBirth; list.Avatar = model.Avatar.ToString().Trim(); list.Gender = model.Gender.ToString().Trim(); list.ModifiedDate = model.CreatedDate.GetValueOrDefault(System.DateTime.Now); list.Status = model.Status.ToString().Trim(); list.SicenceID = model.SicenceID; db.SaveChanges(); model = null; } SetAlert("Cập nhật thông tin thành công! :D", "success"); return(RedirectToAction("Index")); } else if (submit == "Tìm") { if (!string.IsNullOrEmpty(model.Name_Teacher)) { List <Teacher> list = GetData().Where(s => s.Name_Teacher.Contains(model.Name_Teacher)).ToList(); return(View("Index", list)); } else { List <Teacher> list = GetData(); return(View("Index", list)); } } else { List <Teacher> list = GetData().OrderBy(s => s.Name_Teacher).ToList(); return(View("Index", list)); } }
/// <summary> /// Thêm và cập nhật dữ liệu bằng modal popup /// </summary> /// <param name="model"></param> /// <param name="submit"></param> /// <returns></returns> public ActionResult Add(Science model, string submit) { if (submit == "Thêm") { if (model != null) { model.Name = model.Name.ToString().Trim() ?? ""; model.Address = model.Address.ToString().Trim() ?? ""; if (model.Description != null) { model.Description = model.Description; } model.Founding = model.Founding; model.CreatedDate = model.CreatedDate.GetValueOrDefault(System.DateTime.Now); db.Science.Add(model); db.SaveChanges(); model = null; } SetAlert("Thêm thông tin thành công! :D", "success"); return(RedirectToAction("Index")); } else if (submit == "Cập Nhật") { isThemMoi = false; if (model != null) { var list = db.Science.SingleOrDefault(x => x.ID == model.ID); list.Name = model.Name; list.Address = model.Address.ToString(); if (list.Description != null) { list.Description = model.Description; } list.Founding = model.Founding; list.ModifiedDate = model.CreatedDate.GetValueOrDefault(System.DateTime.Now); db.SaveChanges(); model = null; } SetAlert("Cập nhật khoa thành công! :D", "success"); return(RedirectToAction("Index")); } else if (submit == "Tìm") { if (!string.IsNullOrEmpty(model.Name)) { List <Science> list = GetData().Where(s => s.Name.Contains(model.Name)).ToList(); return(View("Index", list)); } else { List <Science> list = GetData(); return(View("Index", list)); } } else { List <Science> list = GetData().OrderBy(s => s.Name).ToList(); return(View("Index", list)); } }
public ActionResult Add(User model, string submit) { if (model.TeacherID != null && model.GroupID == "ADMIN") { SetAlert("Tài khoản Admin không được gán vào Giảng viên! :D", "warning"); return(RedirectToAction("Index")); } var teacherIds = db.User.Where(x => x.TeacherID != null).Select(x => x.TeacherID); List <Teacher> listTeacher = db.Teacher.ToList().Where(x => teacherIds.Contains(x.ID)).ToList(); if (submit == "Thêm") { isThemMoi = true; if (model != null) { model.Name = model.Name.ToString().Trim(); model.UserName = model.UserName.ToString().Trim(); model.Password = Encryptor.MD5Hash(model.Password.Trim()); model.GroupID = model.GroupID; model.Status = model.Status; model.Phone = model.Phone.ToString().Trim(); model.Email = model.Email.ToString().Trim(); model.TeacherID = model.TeacherID; model.CreatedDate = model.CreatedDate.GetValueOrDefault(System.DateTime.Now); if (teacherIds.Contains(model.TeacherID)) { SetAlert("Giảng viên này đã có tài khoản! :D", "warning"); return(RedirectToAction("Index")); } db.User.Add(model); db.SaveChanges(); model = null; } SetAlert("Thêm thông tin thành công! :D", "success"); return(RedirectToAction("Index")); } else if (submit == "Cập Nhật") { isThemMoi = false; if (model != null) { var list = db.User.SingleOrDefault(x => x.ID == model.ID); list.Name = model.Name.ToString().Trim(); list.UserName = model.UserName.ToString().Trim(); if (list.Password != model.Password) { list.Password = Encryptor.MD5Hash(model.Password.Trim()); } list.GroupID = model.GroupID; list.Status = model.Status; list.Phone = model.Phone.ToString().Trim(); list.Email = model.Email.ToString().Trim(); list.ModifiedDate = model.CreatedDate.GetValueOrDefault(System.DateTime.Now); if (teacherIds.Contains(model.TeacherID) && list.TeacherID != model.TeacherID) { SetAlert("Giảng viên này đã có tài khoản! :D", "warning"); return(RedirectToAction("Index")); } list.TeacherID = model.TeacherID; db.SaveChanges(); model = null; } SetAlert("Cập nhật thông tin thành công! :D", "success"); return(RedirectToAction("Index")); } else if (submit == "Tìm") { if (!string.IsNullOrEmpty(model.UserName)) { List <User> list = GetData().Where(s => s.UserName.Contains(model.UserName)).ToList(); return(View("Index", list)); } else { List <User> list = GetData(); return(View("Index", list)); } } else { List <User> list = GetData().OrderBy(s => s.UserName).ToList(); return(View("Index", list)); } }
public ActionResult Add(CalendarWorkingModel data, string submit) { var model = new CalendarWorking { ID = data.ID, Name_CalendarWorking = data.Name_CalendarWorking, Description = data.Description, DateStart = data.DateStart, DateEnd = data.DateEnd, Address = data.Address, WorkState = data.WorkState, Status = data.Status, Files = data.Files, }; var userLogin = (UserLogin)Session[Managing_Teacher_Work.Common.CommonConstants.USER_SESSION]; var checkCalendar = db.CalendarWorking.Where(x => (model.ID != 0 ? x.ID != model.ID : true)).ToList() .Where(x => x.CalendarWorkingTeacher.Select(n => n.TeacherID).ToArray().Intersect(data.TeachersIDArray).Any() && x.DateStart.Date <= model.DateEnd.Date && x.DateEnd.Date >= model.DateStart.Date); var calendarWorkingTeachers = new List <CalendarWorkingTeacher>(); if (checkCalendar.Count() > 0) { SetAlert("Giảng viên đã có lịch công tác trong thời gian này! :D", "error"); return(RedirectToAction("Index")); } if (submit == "Thêm") { isThemMoi = true; if (model != null) { model.Name_CalendarWorking = model.Name_CalendarWorking.ToString(); model.Description = model.Description.ToString(); model.DateStart = model.DateStart; model.DateEnd = model.DateEnd; model.Address = model.Address != null ? model.Address : ""; model.WorkState = model.WorkState; model.Status = model.Status; model.CreatedDate = model.CreatedDate.GetValueOrDefault(System.DateTime.Now); foreach (var item in data.TeachersIDArray) { calendarWorkingTeachers.Add(new CalendarWorkingTeacher { TeacherID = item, CalendarWorkingID = model.ID, }); } model.CalendarWorkingTeacher = calendarWorkingTeachers; db.CalendarWorking.Add(model); db.CalendarWorkingTeacher.AddRange(calendarWorkingTeachers); db.SaveChanges(); model = null; } SetAlert("Thêm thông tin thành công! :D", "success"); return(RedirectToAction("Index")); } else if (submit == "Cập Nhật") { isThemMoi = false; if (model != null) { db.CalendarWorkingTeacher.RemoveRange(db.CalendarWorkingTeacher.Where(x => x.CalendarWorkingID == model.ID)); db.SaveChanges(); var list = db.CalendarWorking.SingleOrDefault(x => x.ID == model.ID); list.Name_CalendarWorking = model.Name_CalendarWorking; list.Description = model.Description; list.DateStart = model.DateStart; list.DateEnd = model.DateEnd; list.Address = model.Address; list.WorkState = model.WorkState; list.Status = model.Status; list.ModifiedDate = model.CreatedDate.GetValueOrDefault(System.DateTime.Now); foreach (var item in data.TeachersIDArray) { calendarWorkingTeachers.Add(new CalendarWorkingTeacher { TeacherID = item, CalendarWorkingID = model.ID, }); } model.CalendarWorkingTeacher = calendarWorkingTeachers; db.CalendarWorkingTeacher.AddRange(calendarWorkingTeachers); db.SaveChanges(); model = null; } SetAlert("Cập nhật thông tin thành công! :D", "success"); return(RedirectToAction("Index")); } else if (submit == "Tìm") { if (!string.IsNullOrEmpty(model.Name_CalendarWorking)) { List <CalendarWorking> list = GetData().Where(s => s.Name_CalendarWorking.Contains(model.Name_CalendarWorking)).ToList(); return(View("Index", list)); } else { List <CalendarWorking> list = GetData(); return(View("Index", list)); } } else { List <CalendarWorking> list = GetData().OrderBy(s => s.Name_CalendarWorking).ToList(); return(View("Index", list)); } }
public ActionResult Add(CalendarWorking model, string submit) { if (submit == "Thêm") { isThemMoi = true; if (model != null) { model.Name_CalendarWorking = model.Name_CalendarWorking.ToString(); model.Description = model.Description.ToString(); model.DateStart = model.DateStart; model.DateEnd = model.DateEnd; model.Address = model.Address != null ? model.Address : ""; model.TeacherID = model.TeacherID; model.WorkID = model.WorkID; model.TypeCalendarID = model.TypeCalendarID; model.WorkState = model.WorkState; model.Status = model.Status; model.CreatedDate = model.CreatedDate.GetValueOrDefault(System.DateTime.Now); db.CalendarWorking.Add(model); db.SaveChanges(); model = null; } SetAlert("Thêm thông tin thành công! :D", "success"); return(RedirectToAction("Index")); } else if (submit == "Cập Nhật") { isThemMoi = false; if (model != null) { var list = db.CalendarWorking.SingleOrDefault(x => x.ID == model.ID); list.Name_CalendarWorking = model.Name_CalendarWorking; list.Description = model.Description; list.DateStart = model.DateStart; list.DateEnd = model.DateEnd; list.Address = model.Address.ToString(); list.TeacherID = model.TeacherID; list.WorkID = model.WorkID; list.TypeCalendarID = model.TypeCalendarID; list.WorkState = model.WorkState; list.Status = model.Status; list.ModifiedDate = model.CreatedDate.GetValueOrDefault(System.DateTime.Now); db.SaveChanges(); model = null; } SetAlert("Cập nhật thông tin thành công! :D", "success"); return(RedirectToAction("Index")); } else if (submit == "Tìm") { if (!string.IsNullOrEmpty(model.Name_CalendarWorking)) { List <CalendarWorking> list = GetData().Where(s => s.Name_CalendarWorking.Contains(model.Name_CalendarWorking)).ToList(); return(View("Index", list)); } else { List <CalendarWorking> list = GetData(); return(View("Index", list)); } } else { List <CalendarWorking> list = GetData().OrderBy(s => s.Name_CalendarWorking).ToList(); return(View("Index", list)); } }
public ActionResult Add(Student model, string submit) { if (submit == "Thêm") { isThemMoi = true; if (model != null) { model.Name_Student = model.Name_Student.ToString().Trim() ?? ""; model.DateOfBirth = model.DateOfBirth; model.Address = model.Address.ToString().Trim() ?? ""; model.Email = model.Email ?? ""; model.Phone = model.Phone.ToString().Trim() ?? ""; model.ClassID = model.ClassID; model.CreatedDate = model.CreatedDate.GetValueOrDefault(System.DateTime.Now); db.Student.Add(model); db.SaveChanges(); model = null; } SetAlert("Thêm thông tin thành công! :D", "success"); return(RedirectToAction("Index")); } else if (submit == "Cập Nhật") { isThemMoi = false; if (model != null) { var list = db.Student.SingleOrDefault(x => x.ID == model.ID); list.Name_Student = model.Name_Student.ToString().Trim(); list.DateOfBirth = model.DateOfBirth; list.Address = model.Address.ToString().Trim(); list.Email = model.Email; list.Phone = model.Phone.ToString().Trim(); list.ClassID = model.ClassID; list.ModifiedDate = model.CreatedDate.GetValueOrDefault(System.DateTime.Now); db.SaveChanges(); model = null; } SetAlert("Cập nhật thông tin thành công! :D", "success"); return(RedirectToAction("Index")); } else if (submit == "Tìm") { if (!string.IsNullOrEmpty(model.Name_Student)) { List <Student> list = GetData().Where(s => s.Name_Student.Contains(model.Name_Student)).ToList(); return(View("Index", list)); } else { List <Student> list = GetData(); return(View("Index", list)); } } else { List <Student> list = GetData().OrderBy(s => s.Name_Student).ToList(); return(View("Index", list)); } }