public static List <EventViewModel> GetMenteeMeetingRequests(ref DAO.ApplicationContext context, int mentorId) { int eventType = DomainHelper.GetIdByKeyValue(ref context, "EventType", "Mentee Meeting Request"); var myEvents = CalendarHelper.GetEvents(ref context) .Where(x => x.EventType == eventType && x.MentorId == mentorId); return((List <EventViewModel>)myEvents.ToList()); }
public static List <EventViewModel> GetPublicEvents(ref DAO.ApplicationContext context) { int eventType = DomainHelper.GetIdByKeyValue(ref context, "EventType", "Public"); var myEvents = CalendarHelper.GetEvents(ref context) .Where(x => x.EventType == eventType); return((List <EventViewModel>)myEvents.ToList()); }
public static List <MenteeViewModel> GetMentees(ref DAO.ApplicationContext context) { int menteeType = DomainHelper.GetValueByKeyValue(ref context, "PersonType", "Mentee").id; var data = (from r in context.People where r.PersonTypeId == menteeType select r).AsEnumerable() .Select(x => new MenteeViewModel { Mentee = x, }); return((List <MenteeViewModel>)data.ToList()); }
public static IEnumerable <SelectListItem> GetMenteesDropdownList(ref DAO.ApplicationContext context) { int menteeType = DomainHelper.GetValueByKeyValue(ref context, "PersonType", "Mentee").id; var data = (from r in context.People where r.PersonTypeId == menteeType select r).AsEnumerable() .Select(x => new SelectListItem { Text = x.LastName + ", " + x.FirstName, Value = x.id.ToString() }).ToList(); data.Insert(0, new SelectListItem { Value = "0", Text = "Please select ..." }); return(data); }
public static IEnumerable <ResourceViewModel> GetResources(ref MMS.DAO.ApplicationContext context) { MMS.DAO.ApplicationContext tempContext = context; var resources = (from r in context.Resources select r).AsEnumerable() .Select(x => new ResourceViewModel { id = x.id, Name = x.Name, Type = x.Type, UploadDate = x.UploadDate, Description = x.Description, Location = x.Location, RelativeUrl = x.RelativeUrl, DocumentType = DomainHelper.GetValueById(ref tempContext, x.Type) }).ToList(); return(resources); }
public static Address GetAddressByPersonAndType(ref ApplicationContext context, int personId, string addressType) { int addrType = DomainHelper.GetIdByKeyValue(ref context, "AddressType", addressType); var homeAddr = (from r in context.PersonToAddress where r.PersonId == personId && r.AddressType == addrType select r).FirstOrDefault(); if (homeAddr != null) { var addr = (from r in context.Addresses where r.id == homeAddr.AddressId select r).FirstOrDefault(); return((Address)addr); } else { return(null); } }
public static RegistrationViewModel FindRegistration(ref DAO.ApplicationContext context, string username) { int personId = AccountHelper.GetUserIdByUsername(ref context, username); if (personId > 0) { RegistrationViewModel viewModel = new RegistrationViewModel(); int homeAddrType = DomainHelper.GetIdByKeyValue(ref context, "AddressType", "Home"); int workAddrType = DomainHelper.GetIdByKeyValue(ref context, "AddressType", "Work"); MentorApplication data = (MentorApplication)(from r in context.MentorApplications where r.PersonId == personId select r).FirstOrDefault(); UserProfile profile = (UserProfile)(from r in context.UserProfiles where r.PersonId == personId select r).FirstOrDefault(); Person mentor = (Person)(from r in context.People where r.id == personId select r).FirstOrDefault(); Address homeAddr = (Address)(from r in context.Addresses join c in context.PersonToAddress on r.id equals c.AddressId where c.PersonId == personId && c.AddressType == homeAddrType select r).FirstOrDefault(); Address workAddr = (Address)(from r in context.Addresses join c in context.PersonToAddress on r.id equals c.AddressId where c.PersonId == personId && c.AddressType == workAddrType select r).FirstOrDefault(); viewModel.AgreeToTerms = data.AgreeToTerms; viewModel.Availability = data.Availability; viewModel.DateOfBirth = mentor.DOB; viewModel.FelonyArrested = mentor.FelonyArrested; viewModel.FelonyConvicted = mentor.FelonyConvicted; viewModel.FelonyDescription = mentor.FelonyDescription; viewModel.FirstName = mentor.FirstName; viewModel.GenderId = mentor.GenderId; viewModel.HasRelationIncarcerated = data.HasRelationIncarcerated; viewModel.HomeAddress = homeAddr; viewModel.LastName = mentor.LastName; viewModel.LeadershipSkills = data.LeadershipSkills; viewModel.MaidenName = mentor.MaidenName; viewModel.MiddleInitial = mentor.MiddleInitial; viewModel.MinistryExperience = data.MinistryExperience; viewModel.MinistryId = data.MinistryId; viewModel.MisdemeanorArrested = mentor.MisdemeanorArrested; viewModel.MisdemeanorConvicted = mentor.MisdemeanorConvicted; viewModel.MisdemeanorDescription = mentor.MisdemeanorDescription; viewModel.PersonId = mentor.id; viewModel.PrefixId = mentor.PrefixId; viewModel.RaceId = mentor.RaceId; viewModel.RelationIncarceratedName = data.RelationIncarceratedName; viewModel.RelationIncarceratedNumber = data.RelationIncarceratedNumber; viewModel.RelationIncarceratedType = data.RelationIncarceratedType; viewModel.RelativesWorkingForDoC = data.RelativesWorkingForDoC; viewModel.RelativeWorkingForDoCName = data.RelativeWorkingForDoCName; viewModel.RelativeWorkingForDoCRelationType = data.RelativeWorkingForDoCRelationType; viewModel.RelativeWorkingForDoCWorkLocation = data.RelativeWorkingForDoCWorkLocation; viewModel.SocialSecurityNumber = mentor.SSN; viewModel.SpecialHobbies = data.SpecialHobbies; viewModel.SpecialRequests = data.SpecialRequests; viewModel.StateDl = mentor.StateDl; viewModel.StateWhereDlIssued = mentor.StateWhereDlWasIssued; viewModel.SuffixId = mentor.SuffixId; if (data.WhenWorkedEnded != null) { viewModel.WhenWorkedEnded = data.WhenWorkedEnded.Value; } if (data.WhenWorkedStarted != null) { viewModel.WhenWorkedStarted = data.WhenWorkedStarted.Value; } viewModel.WhereDidYouWork = data.WhereDidYouWork; viewModel.WorkAddress = workAddr; viewModel.WorkedForDoC = data.WorkedForDoC; viewModel.Username = profile.Username; return(viewModel); } else { return(null); } }