public ActionResult Index() { ViewBag.Showing = "Home"; var homeView = new HomeView() { GeneralInformations = new List <GeneralInformation>(), InformationDesks = new List <InformationDesk>(), ContactSummary = new ContactSummary() }; var gses = _coreRepo.GetAll <GeneralInformation>().ToList(); foreach (var gs in gses) { if (gs.ShortDescription == null) { var sd = _generalHelper.ConvertHtmlToPlainText(gs.Content); gs.ShortDescription = sd.Length > summaryLength?sd.Substring(0, summaryLength) + "... " : sd; } else { gs.ShortDescription = gs.ShortDescription.Length > summaryLength ? gs.ShortDescription.Substring(0, summaryLength) + "... " : gs.ShortDescription + "..."; } homeView.GeneralInformations.Add(gs); } var ides = _coreRepo.GetAll <InformationDesk>().ToList(); foreach (var id in ides) { if (id.ShortDescription == null) { var sd = _generalHelper.ConvertHtmlToPlainText(id.Content); id.ShortDescription = sd.Length > summaryLength?sd.Substring(0, summaryLength) + "... " : sd; } else { id.ShortDescription = id.ShortDescription.Length > summaryLength?id.ShortDescription.Substring(0, summaryLength) + "... " : id.ShortDescription + "..."; } homeView.InformationDesks.Add(id); } //now retrieving contacts... var university = _coreRepo.GetAll <Institution>().FirstOrDefault(); homeView.University = university; return(View(homeView)); }
public string LoadStaffRoles() { IEnumerable <PositionCategory> staffRoles = _coreRepository.GetAll <PositionCategory>(); IEnumerable <SelectListItem> loadedroles = staffRoles.Select(x => new SelectListItem { Text = x.Name, Value = x.Id.ToString() }); return(JsonConvert.SerializeObject(loadedroles)); }
public ActionResult Index() { string userId = User.Identity.GetUserId(); var homeView = new StaffHomeView() { staff = new Instructor(), InformationDesks = new List <InformationDesk>(), semInfo = new SemesterProgressSummary() }; Instructor staffInfo = _staffRepo.GetStaffByUserId(int.Parse(userId)); if (staffInfo.Person.ProfilePhotoName != null) { staffInfo.Person.ProfilePhotoUrl = Path.Combine(ApplicationConstants.StaffResourcesThumbnailUrl, staffInfo.Person.ProfilePhotoName); } homeView.staff = staffInfo; //Need to limit to the number to be displayed (4) var ides = _coreRepo.GetAll <InformationDesk>().ToList(); foreach (var id in ides) { if (id.ShortDescription == null) { var sd = _generalHelper.ConvertHtmlToPlainText(id.Content); id.ShortDescription = sd.Length > summaryLength?sd.Substring(0, summaryLength) + "... " : sd; } else { id.ShortDescription = id.ShortDescription.Length > summaryLength?id.ShortDescription.Substring(0, summaryLength) + "... " : id.ShortDescription + "..."; } homeView.InformationDesks.Add(id); } // Get Semester Progress DateTime today = DateTime.Now; Cohort currentSemester = new Cohort(); currentSemester = _semesterRepository.GetCurrentSemester(today); homeView.semInfo = currentSemester == null ? null : new SemesterProgressSummary(); return(View(homeView)); }
public ActionResult Index() { var model = new WITU.Models.AuditViewList() { AuditRecords = _coreRepo.GetAll <Audit>().Select(x => new AuditTrail() { UserType = x.UserType, UserName = x.UserName, IpAddress = x.IpAddress, UrlAccessed = x.UrlAccessed, Message = x.Message, Data = x.Data, TimeAccessed = x.TimeAccessed }).ToList() }; @ViewBag.TrailGroup = "All"; return(View(model)); }
public ActionResult StaffPersonalDetails(UserInfoViewModel model, string buttonClicked, HttpPostedFileBase file) { try { //When no staff details exist i.e Add new staff details if (model.User.Id <= 0 && model.Person.Surname == null) { ViewBag.CountryId = ViewBag.CountryId ?? new SelectList(_coreRepo.GetAll <Country>(), "Id", "Name", model); return(PartialView("_editStaffPersonalDetails", model)); } //if (model.User.Id > 0) //{ //Check whether username already exists if (model.User.Id <= 0 && _coreRepo.Get <User>("Username", model.User.Username) != null) { ModelState.AddModelError("Error", "The username chosen already exists!"); ViewBag.CountryId = ViewBag.CountryId ?? new SelectList(_coreRepo.GetAll <Country>(), "Id", "Name", model); return(PartialView("_editStaffPersonalDetails", model)); } var user = _coreRepo.Get <User>(model.User.Id); //Retrieving Existing Staff Member Instructor staff = _staffRepo.GetStaffByUserId(model.User.Id); if (buttonClicked == "Save") { //Saving or Updating Person Person person = staff != null ? staff.Person : new Person(); person.Title = model.Person.Title; person.Surname = model.Person.Surname; person.GivenName = model.Person.GivenName; person.OtherName = model.Person.OtherName; person.Gender = model.Person.Gender; person.DateOfBirth = model.Person.DateOfBirth; person.MaritalStatus = model.Person.MaritalStatus; person.Religion = model.Person.Religion; person.Country2 = model.Person.Country2 != null ? model.Person.Country2.Id > 0 ? _coreRepo.Get <Country>(model.Person.Country2.Id) : model.Person.Country : null; person.Country = model.Person.Country2 != null ? model.Person.Country2.Id > 0 ? _coreRepo.Get <Country>(model.Person.Country2.Id) : model.Person.Country : null; person.Country1 = model.Person.Country2 != null ? model.Person.Country2.Id > 0 ? _coreRepo.Get <Country>(model.Person.Country2.Id) : model.Person.Country : null; person.PlaceOfBirth = model.Person.Country2 != null ? model.Person.Country2.Id > 0 ? _coreRepo.Get <Country>(model.Person.Country2.Id).Name : null : null; string newFileName = null; if (file != null) { if (_generalHelper.SaveFile(file, ApplicationConstants.StaffResourcesFolder, out newFileName, model.User.ProfilePhotoName)) { _generalHelper.ResizeImage(file, ResourceFolders.ThumbnailSmall, ApplicationConstants.StaffResourcesFolder, newFileName, !string.IsNullOrEmpty(model.User.ProfilePhotoName)? model.User.ProfilePhotoName : string.IsNullOrEmpty(model.Person.ProfilePhotoName) ? null : model.Person.ProfilePhotoName); } _generalHelper.ResizeImage(file, ResourceFolders.Thumbnail, ApplicationConstants.StaffResourcesFolder, newFileName, !string.IsNullOrEmpty(model.User.ProfilePhotoName) ? model.User.ProfilePhotoName : string.IsNullOrEmpty(model.Person.ProfilePhotoName) ? null : model.Person.ProfilePhotoName); model.User.ProfilePhotoName = newFileName; person.ProfilePhotoName = newFileName; } person.PostalAddress = model.Person.PostalAddress; person.EmailAddress = model.Person.EmailAddress; person.AltEmailAddress = model.Person.AltEmailAddress; person.TelephoneContact = model.Person.TelephoneContact; person.NextOfKinName = model.Person.NextOfKinName; person.NextOfKinRelationship = model.Person.NextOfKinRelationship; person.NextOfKinContact = model.Person.NextOfKinContact; person.NextOfKinAddress = model.Person.NextOfKinAddress; person.WebsiteUrl = model.Person.WebsiteUrl; person.PersonOwnerType = int.Parse(ApplicationConstants.StaffUserType); person.LastModified = DateTime.Now; if (model.User.Id <= 0) { person.CreatedOn = DateTime.Now; } //now saving User Information if (_coreRepo.SaveOrUpdate(person)) { //Saving or Updating the User Information in the User Table User userAccount = user ?? new User(); userAccount.Username = model.User.Username; userAccount.Email = person.EmailAddress; userAccount.UserType = int.Parse(ApplicationConstants.StaffUserType); userAccount.IsApproved = true; userAccount.IsLockedOut = false; userAccount.IsFirstTimeUser = user == null; if (!string.IsNullOrEmpty(newFileName)) { userAccount.ProfilePhotoName = newFileName; } if (_coreRepo.SaveOrUpdate(userAccount)) { staff = staff ?? new Instructor(); staff.Person = person; staff.User = userAccount; staff.CreatedOn = DateTime.Now; if (_coreRepo.SaveOrUpdate(staff)) { //Set Password to Default Password if new user var userAccountSaved = _coreRepo.Get <User>(userAccount.Id); if (userAccountSaved != null && userAccountSaved.Password == null && userAccountSaved.PasswordKey == null) { IdentityResult result = UserManager.AddPassword(userAccountSaved.Id, ApplicationConstants.DEFAULT_STUDENT_PASSWORD); if (result.Succeeded) { ; } } } //Redirect so as to refresh the view details return(JavaScript("window.location = '" + Url.Action("StaffDetails", "UserManagement", new { id = userAccount.Id }) + "'")); } } } if (user != null) { staff = _staffRepo.GetStaffByUserId(model.User.Id); model.User = user; model.Person = staff.Person; if (model.Person.ProfilePhotoName != null) { model.Person.ProfilePhotoUrl = Path.Combine(ApplicationConstants.StaffResourcesThumbnailUrl, staff.Person.ProfilePhotoName); } else if (model.User.ProfilePhotoName != null) { model.Person.ProfilePhotoUrl = Path.Combine(ApplicationConstants.StaffResourcesThumbnailUrl, staff.User.ProfilePhotoName); } else { model.Person.ProfilePhotoUrl = ApplicationConstants.ProfilePhotoAvartarUrl; } ViewBag.CountryId = ViewBag.CountryId ?? new SelectList(_coreRepo.GetAll <Country>(), "Id", "Name", model); } if (buttonClicked == "Edit") { ViewBag.CountryId = ViewBag.CountryId ?? new SelectList(_coreRepo.GetAll <Country>(), "Id", "Name", model); return(PartialView("_editStaffPersonalDetails", model)); } //} return(PartialView("_StaffPersonalDetails", model)); } catch (Exception e) { throw e; } }
public IList <Employee> GetAllEmployees() { return(_employeeRepository.GetAll().OrderBy(m => m.LastName).ToList()); }