Beispiel #1
0
        public static List <EventViewModel> GetEventsByUserId(ref DAO.ApplicationContext context, int creatorId)
        {
            var myEvents = CalendarHelper.GetEvents(ref context)
                           .Where(x => x.CreatorId == creatorId);

            return((List <EventViewModel>)myEvents.ToList());
        }
Beispiel #2
0
        public static List <MessageViewModel> GetMessagesFromUserId(ref DAO.ApplicationContext context, int fromUserId)
        {
            List <MessageViewModel> msgs = (List <MessageViewModel>)GetMessages(ref context)
                                           .Where(x => x.FromUserId == fromUserId).ToList();

            return(msgs);
        }
Beispiel #3
0
        public static IEnumerable <ContactLogViewModel> GetContactLogsByMenteeId(ref DAO.ApplicationContext context, int personId)
        {
            List <ContactLogViewModel> logs = (List <ContactLogViewModel>)GetContactLogs(ref context)
                                              .Where(x => x.MenteeId == personId).ToList();

            return(logs);
        }
Beispiel #4
0
        public static List <UserProfileViewModel> GetUserProfilesByRoleName(ref DAO.ApplicationContext context, string roleName)
        {
            List <UserProfileViewModel> users = (List <UserProfileViewModel>)GetUserProfiles(ref context)
                                                .Where(x => x.UserRole.Name == roleName).ToList();

            return(users);
        }
Beispiel #5
0
        public static List <EventViewModel> GetEventsForMentee(ref DAO.ApplicationContext context, int menteeId)
        {
            var myEvents = CalendarHelper.GetEvents(ref context)
                           .Where(x => x.MenteeId == menteeId);

            return((List <EventViewModel>)myEvents.ToList());
        }
Beispiel #6
0
        public static List <UserProfileViewModel> GetUserProfilesByRoleId(ref DAO.ApplicationContext context, int roleId)
        {
            List <UserProfileViewModel> users = (List <UserProfileViewModel>)GetUserProfiles(ref context)
                                                .Where(x => x.UserRole.id == roleId).ToList();

            return(users);
        }
Beispiel #7
0
        public static UserProfileViewModel GetUserProfileByUsername(ref DAO.ApplicationContext context, string username)
        {
            UserProfileViewModel user = (UserProfileViewModel)GetUserProfiles(ref context)
                                        .Where(x => x.UserProfile.Username == username).FirstOrDefault();

            return(user);
        }
Beispiel #8
0
        public static UserProfileViewModel GetUserProfileByPersonId(ref DAO.ApplicationContext context, int personId)
        {
            UserProfileViewModel user = (UserProfileViewModel)GetUserProfiles(ref context)
                                        .Where(x => x.Person.id == personId);

            return(user);
        }
Beispiel #9
0
        public static List <MessageViewModel> GetMessagesToUserId(ref DAO.ApplicationContext context, int toUserId)
        {
            List <MessageViewModel> msgs = (List <MessageViewModel>)GetMessages(ref context)
                                           .Where(x => x.ToUserId == toUserId).OrderByDescending(x => x.Created).ToList();

            return(msgs);
        }
Beispiel #10
0
        public static UserProfile GetUsernameByUserId(ref DAO.ApplicationContext context, int id)
        {
            var data = (from r in context.UserProfiles
                        where r.id == id
                        select r).FirstOrDefault();

            return(data);
        }
Beispiel #11
0
        public static MentorApplication GetMentorApplicationByPersonId(ref DAO.ApplicationContext context, int id)
        {
            MentorApplication application = (from r in context.MentorApplications
                                             where r.PersonId == id
                                             select r).FirstOrDefault();

            return(application);
        }
Beispiel #12
0
        public static int GetUserIdByUsername(ref DAO.ApplicationContext context, string username)
        {
            var user = (from r in context.People
                        join p in context.UserProfiles on r.id equals p.PersonId
                        where p.Username == username
                        select r).FirstOrDefault();

            return((user != null) ? user.id : 0);
        }
Beispiel #13
0
        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());
        }
Beispiel #14
0
        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());
        }
Beispiel #15
0
        public static string GetUserRoleByUsername(ref DAO.ApplicationContext context, string username)
        {
            var data = (from r in context.UserProfiles
                        join p in context.UserRoles on r.RoleId equals p.id
                        where r.Username == username
                        select p.Name).FirstOrDefault();

            return((string)data);
        }
Beispiel #16
0
        public static IEnumerable <ContactLogViewModel> GetContactLogsByMinistryId(ref DAO.ApplicationContext context, int ministryId)
        {
            var contactLogs = context.ContactLogs.ToList();
            var logs        = (from r in GetContactLogs(ref context)
                               join c in context.Ministries on r.MinistryId equals c.id
                               where c.id == ministryId
                               select r).ToList();

            return((List <ContactLogViewModel>)logs);
        }
Beispiel #17
0
 public MessageViewModel(ref DAO.ApplicationContext context, Message msg)
 {
     this.MessageId  = msg.id;
     this.ToUserId   = msg.ToUserId;
     this.ToUser     = Helpers.AccountHelper.GetUsernameByUserId(ref context, msg.ToUserId).Username;
     this.FromUserId = msg.FromUserId;
     this.FromUser   = Helpers.AccountHelper.GetUsernameByUserId(ref context, msg.FromUserId).Username;
     this.Created    = msg.Created;
     this.Subject    = msg.Subject;
     this.Body       = msg.Body;
 }
Beispiel #18
0
        public static List <UserProfileViewModel> GetUserProfiles(ref DAO.ApplicationContext context)
        {
            var users = (from r in context.UserProfiles
                         join p in context.UserRoles on r.RoleId equals p.id
                         join c in context.People.DefaultIfEmpty() on r.PersonId equals c.id
                         select new UserProfileViewModel
            {
                UserProfile = r,
                UserRole = p,
                Person = c
            }).ToList();

            return((List <UserProfileViewModel>)users);
        }
Beispiel #19
0
        public static MentorViewModel GetMentorById(ref DAO.ApplicationContext context, int personId)
        {
            MentorViewModel mentor = new MentorViewModel();

            mentor.Person = (from r in context.People
                             where r.id == personId
                             select r).First();

            mentor.HomeAddress = AddressHelper.GetAddressByPersonAndType(ref context, personId, "Home");
            mentor.WorkAddress = AddressHelper.GetAddressByPersonAndType(ref context, personId, "Work");
            mentor.MinistryId  = MinistryHelper.GetMinistryByPersonId(ref context, personId);

            return(mentor);
        }
Beispiel #20
0
        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());
        }
Beispiel #21
0
        public static IEnumerable <SelectListItem> GetValidEventsDropdown(ref DAO.ApplicationContext context)
        {
            var events = (from r in context.Events
                          where r.EventBegins >= DateTime.Today
                          where r.EventEnds <= DateTime.Today
                          select r).AsEnumerable()
                         .Select(x => new SelectListItem
            {
                Value = x.id.ToString(),
                Text  = x.EventName
            }).ToList();

            events.Insert(0, new SelectListItem {
                Value = "0", Text = "Please select ..."
            });

            return(events);
        }
Beispiel #22
0
        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);
        }
Beispiel #23
0
        public static IEnumerable <ContactLogViewModel> GetContactLogs(ref DAO.ApplicationContext context)
        {
            var contactLogs = context.ContactLogs.ToList();
            var logs        = (from r in contactLogs
                               join c in context.People on r.MentorId equals c.id
                               join d in context.People on r.MenteeId equals d.id
                               orderby r.ContactDate descending
                               select new ContactLogViewModel
            {
                ContactLogId = r.id,
                ContactDate = r.ContactDate.ToString("s"),
                MenteeName = c.LastName + ", " + c.FirstName,
                MentorName = c.LastName + ", " + c.LastName,
                ActivityTypeId = r.ActivityTypeId,
                ContactTypeId = r.ContactTypeId
            }).AsEnumerable();

            return(logs);
        }
Beispiel #24
0
        public static IEnumerable <EventViewModel> GetEvents(ref DAO.ApplicationContext context)
        {
            var evts = (from r in context.Events
                        orderby r.EventBegins
                        select new EventViewModel
            {
                id = r.id,
                CreatorId = r.CreatorId,
                EventName = r.EventName,
                EventDetails = r.EventDetails,
                EventUrl = r.EventUrl,
                EventBegins = r.EventBegins,
                EventEnds = r.EventEnds,
                AllDayEvent = r.AllDayEvent,
                EventType = r.EventType,
                MentorId = r.MentorId,
                MenteeId = r.MenteeId,
                SignupId = r.SignupId
            }).AsEnumerable();

            return(evts);
        }
Beispiel #25
0
        public static List <MessageViewModel> GetMessages(ref DAO.ApplicationContext context)
        {
            // Get messages for this mentor
            var messages = context.Messages.ToList();

            var msgs = (from r in messages
                        join c in context.UserProfiles on r.ToUserId equals c.id
                        join p in context.UserProfiles on r.FromUserId equals p.id
                        orderby r.Created ascending
                        select new MessageViewModel
            {
                MessageId = r.id,
                FromUserId = r.FromUserId,
                FromUser = p.Username,
                ToUserId = r.ToUserId,
                ToUser = WebMatrix.WebData.WebSecurity.CurrentUserName,
                Created = r.Created,
                IsFlashTraffic = r.IsFlashTraffic,
                Subject = r.Subject,
                Body = r.Body
            }).ToList();

            return((List <MessageViewModel>)msgs);
        }
Beispiel #26
0
        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);
            }
        }