public async Task<ActionResult> Index() { #region Get Identity BusinessLogicHandler _gateWay = new BusinessLogicHandler(); ApplicationDbContext dataSocket = new ApplicationDbContext(); UserStore<ApplicationUser> myStore = new UserStore<ApplicationUser>(dataSocket); ApplicationUserManager UserManager = new ApplicationUserManager(myStore); var _user = await UserManager.FindByNameAsync(User.Identity.Name); Lecturer _staff = new Lecturer(); _staff = _gateWay.GetLecturer(_user.Id.ToString()); #endregion #region Get The Modules AttendanceViewModel _model = new AttendanceViewModel(); List<Module> _modList = new List<Module>(); List<SelectListItem> _selectList = new List<SelectListItem>(); _modList = _gateWay.GetModulesForLecturer(_staff.StaffNumber); foreach (var _mod in _modList) { _selectList.Add(new SelectListItem { Text = _mod.ModuleName, Value = _mod.ModuleCode }); } #endregion #region Get The Venues List<Venue> _venueList = new List<Venue>(); List<SelectListItem> _vlist = new List<SelectListItem>(); _venueList = _gateWay.GetAllVenues(); foreach (Venue _venue in _venueList) { _vlist.Add(new SelectListItem { Text = _venue.VenueName, Value = _venue.VenueCode }); } #endregion #region Getting the lectures List<Lecture> _lectureList = new List<Lecture>(); List<SelectListItem> _yetAL = new List<SelectListItem>(); _lectureList = _gateWay.GetLecturesForStaff(_staff.StaffNumber); _yetAL.Add(new SelectListItem { Text = "Select Lecture", Value = "0", Selected = true }); foreach (var _item in _lectureList) { _yetAL.Add(new SelectListItem { Text = _item.ModuleCode + " " + _item.TimeSlot, Value = _item.LUI.ToString() }); } #endregion ViewData["Lecture"] = _yetAL; //ViewData["Modules"] = _selectList; //ViewData["Venues"] = _vlist; //_model.Venues = _vlist; _model.Lectures = _yetAL; //_model.Modules = _selectList; return View(_model); }
public ActionResult Details(string selectedValue) { AttendanceViewModel _model = new AttendanceViewModel(); BusinessLogicHandler _gateWay = new BusinessLogicHandler(); _model.Lecture = new Lecture(); _model.Lecture = _gateWay.GetLecture(int.Parse(selectedValue)); object[] response = { _model.Lecture.ModuleCode, _model.Lecture.VenueCode, _model.Lecture.TimeSlot }; return Json(response); }