public ActionResult StudentAttendense(Guid sessionId) { var sessionRepo = new SessionRepository(); var students = sessionRepo.GetByRowId(sessionId).session_participant.Select(x => x.participant_profile).ToList(); return(View(students)); }
// GET: Funder public ActionResult Index(string sortOrder, string filter, string archived, int page = 1, Guid?archive = null) { ViewBag.searchQuery = string.IsNullOrEmpty(filter) ? "" : filter.Trim(); ViewBag.showArchived = (archived ?? "") == "on"; page = page > 0 ? page : 1; int pageSize = 0; pageSize = pageSize > 0 ? pageSize : 10; ViewBag.CurrentSort = sortOrder; IEnumerable <session> session; var repository = new SessionRepository(); repository.SetOccuredStatus(); if (archive != null) { var oSession = repository.GetByRowId(archive.Value); oSession.IsActive = !oSession.IsActive; repository.Put(oSession.Id, oSession); } var cu = Session["user"] as ContextUser; int corSchoolId = 0; if (cu.EnumRole != EnumUserRole.Volunteer) { corSchoolId = new CoordinatorRepository().GetSchoolIdByUserId(cu.OUser.Id); } var participantId = 0; if (cu.EnumRole == EnumUserRole.Participant) { participantId = new ParticipiantRepository().GetByUserId(cu.OUser.Id).Id; } session = repository.Get().Where(x => { return((filter == null || x.ProgramName.ToLower().Contains(filter.ToLower()) || (x.school != null && (x.school.SchoolName.ToLower().Contains(filter.ToLower()) || x.school.City.ToLower().Contains(filter.ToLower()))) ) && ((cu.EnumRole == EnumUserRole.SuperAdmin || (cu.EnumRole == EnumUserRole.Participant && x.session_participant .Select(y => y.ParticipantID) .Contains(participantId)) || (cu.EnumRole == EnumUserRole.Volunteer && ((x.VolunteerId == null && x.Status == "Approved") || (x.VolunteerId.HasValue && x.VolunteerId.Value == cu.OUser.Id && (x.Status == "Approved" || x.Status == "Occured")))) || (cu.EnumRole == EnumUserRole.Coordinator && x.SchoolID == corSchoolId)))); }); //Sorting order session = session.OrderByDescending(x => x.CreatedAt); ViewBag.Count = session.Count(); return(View(session.ToPagedList(page, pageSize))); }
public ActionResult StudentAttendense(List <participant_profile> participants) { var sessionRepo = new SessionRepository(); Guid sessionId = Guid.Parse(Request.Form["sessionid"]); if (participants == null || participants.Count == 0) { return(RedirectToAction("Index")); } int[] selectedParticipant = participants.Where(x => x.IsSelected).Select(x => x.Id).ToArray(); var session = sessionRepo.GetByRowId(sessionId); var sessionParticipants = session.session_participant.Where(x => selectedParticipant.Contains(x.ParticipantID)).ToList(); sessionParticipants.ForEach(x => x.VolunteerMarkedAttendence = true); // send email to coordinator var corEmail = session.school.coordinator_profile.First().CoordinatorEmail; var bogusController = Util.CreateController <EmailTemplateController>(); EmailTemplateModel emodel = new EmailTemplateModel { Title = "Notification: student attendense marked as completed.", VolunteerName = session.volunteer_profile.VolunteerName, SessionTitle = session.ProgramName, CoordinatorName = session.school.coordinator_profile.First().CoordinatorName }; string body = Util.RenderViewToString(bogusController.ControllerContext, "VolunteerConfirmAttendense", emodel); EmailSender.SendSupportEmail(body, corEmail); //send email to manager var adminEmail = new AccountRepository().Get(session.CreatedBy).Email; EmailSender.SendSupportEmail(body, adminEmail); session.VolunteerMarkedStudentAttendenceInSession = true; session.MarkedCompletedByVolunteer = true; sessionRepo.Put(session.Id, session); return(RedirectToAction("Index")); }
public ActionResult Edit(Guid?id, int page = 1) { SelectListItem defaultselect = new SelectListItem { Text = General.Select, Value = "0" }; var school = new SchoolRepository().Get().Select(x => new SelectListItem { Text = x.SchoolName, Value = x.Id + "" }).ToList(); school.Insert(0, defaultselect); ViewBag.school = school; var volunteer = new VolunteerRepository().GetApprovedVolunteer().Select(x => new SelectListItem { Text = x.VolunteerName, Value = x.Id + "" }).ToList(); volunteer.Insert(0, defaultselect); ViewBag.volunteer = volunteer; var certificatesVolunteer = new CertificateRepository().Get().Where(x => x.TypeCertificate == "Volunteer").Select(x => new SelectListItem { Text = x.Name, Value = x.Id + "" }).ToList(); certificatesVolunteer.Insert(0, defaultselect); ViewBag.certificatesVolunteer = certificatesVolunteer; var certificatesStudent = new CertificateRepository().Get().Where(x => x.TypeCertificate == "Student").Select(x => new SelectListItem { Text = x.Name, Value = x.Id + "" }).ToList(); certificatesStudent.Insert(0, defaultselect); ViewBag.certificatesStudent = certificatesStudent; var evaluationCatagory = new EvaluationFormRepository().Get().GroupBy(x => x.Catagory).Select(x => x.First()).Select(x => new SelectListItem { Text = x.Catagory, Value = x.Catagory + "" }).ToList(); evaluationCatagory.Insert(0, defaultselect); ViewBag.evaluationCatagory = evaluationCatagory; var cu = Session["user"] as ContextUser; session sessionModel; if (id == null) { sessionModel = new session(); sessionModel.IsActive = true; sessionModel.PropesedDateString = DateTime.Now.AddMonths(1).ToString("dd/MM/yyyy"); } else { var sessionRepo = new SessionRepository(); sessionModel = sessionRepo.GetByRowId(id.Value); sessionModel.PropesedDateString = sessionModel.ProposedDateTime.ToString("dd/MM/yyyy"); sessionModel.EnumSessionStatus = (SessionStatus)Enum.Parse(typeof(SessionStatus), sessionModel.Status); if (sessionModel.ActualDateTime != null) { sessionModel.ActualDateString = sessionModel.ActualDateTime.Value.ToString("dd/MM/yyyy"); if ((sessionModel.ActualDateTime.Value.Date - DateTime.Now.Date).Hours >= 72 && sessionModel.EnumSessionStatus == SessionStatus.Approved && cu.EnumRole == EnumUserRole.Coordinator) { sessionModel.ChangeDateVisible = true; } } if (cu.EnumRole == EnumUserRole.Participant) { string eve_cat = sessionModel.StudentEvaluationCatagory; if (!string.IsNullOrEmpty(eve_cat)) { int participantId = new ParticipiantRepository().GetByUserId(cu.OUser.Id).Id; var sParticipant = sessionModel.session_participant.Where(x => x.ParticipantID == participantId).First(); sessionModel.EvaluationFormFilled = (sParticipant.IsPreEvaluated ?? false) && (sParticipant.IsPostEvaluated ?? false); sessionModel.IsPreFilledByStudent = (sParticipant.IsPreEvaluated ?? false); sessionModel.IsPostFilledByStudent = (sParticipant.IsPostEvaluated ?? false); sessionModel.IsAttendenseMarked = sParticipant.VolunteerMarkedAttendence; } } if (cu.EnumRole == EnumUserRole.Coordinator) { sessionModel.IsFilledCoordinator = new EvaluationVolunteerRepository().GetEvaluationForm(sessionModel.Id) != null; } if (cu.EnumRole == EnumUserRole.Volunteer) { sessionModel.IsFilledVolunteer = new EvaluationCoordinatorRepository().GetEvaluationForm(sessionModel.Id) != null; } var session_evaluationform_photo = sessionModel.session_evaluationform_photo.Select(x => x.FilePath).ToArray(); sessionModel.EvaluationImageLink = string.Join(",", session_evaluationform_photo) + ","; var session_photo = sessionModel.session_photo.Select(x => x.FilePath).ToArray(); sessionModel.SessionImageLink = string.Join(",", session_photo) + ","; sessionModel.PagedParticipants = sessionModel.session_participant.Select(x => x.participant_profile).OrderByDescending(x => x.CreatedAt).ToPagedList(page, 5); ViewBag.Count = sessionModel.session_participant.Count(); ViewBag.IsSessionEnabledForVolunteer = true; } return(View(sessionModel)); }