IUserSchedule IMeetingRetriever.GetUserBusyTime(int entryId)
 {
     using (ManagementSystemDataContext dataContext = new ManagementSystemDataContext(_connectionString))
     {
         return(dataContext.UserScheduleDtos.Single(c => c.IndexId == entryId));
     }
 }
        //TODO: Implement interface methods.

        #region IMeetingRetriever Members

        List <IMeetingMaster> IMeetingRetriever.GetAllMeetingsByUser(IUser user)
        {
            using (ManagementSystemDataContext dataContext = new ManagementSystemDataContext(_connectionString))
            {
                List <IMeetingMaster> meetings = new List <IMeetingMaster>();

                List <int> meetingIds = (from schedules in dataContext.Meeting_ResponseDtos
                                         where schedules.FKUserId == user.UserId &&
                                         schedules.MeetingId != 0
                                         select schedules.MeetingId).ToList();

                if (meetingIds.Count != 0)
                {
                    foreach (int id in meetingIds)
                    {
                        meetings.Add(dataContext.Meeting_MasterDtos.Single(c => c.MeetingId == id));
                    }

                    return(meetings);
                }
                else
                {
                    return(new List <IMeetingMaster>());
                }
            }
        }
 public ICustomSetting GetCustomSettings()
 {
     using (ManagementSystemDataContext dataContext = new ManagementSystemDataContext(_connectionString))
     {
         return(dataContext.CustomSettingDtos.First());
     }
 }
 IUser IUserRetriever.GetUserById(int userId)
 {
     using (ManagementSystemDataContext dataContext = new ManagementSystemDataContext(_connectionString))
     {
         return(dataContext.UserDtos.SingleOrDefault(
                    w => w.UserId == userId));
     }
 }
 void IMeetingScheduler.RemoveUserBusyTime(int userScheduleIndexId)
 {
     using (ManagementSystemDataContext dataContext = new ManagementSystemDataContext(_connectionString))
     {
         dataContext.UserScheduleDtos.DeleteAllOnSubmit(dataContext.UserScheduleDtos.Where(c => c.IndexId == userScheduleIndexId));
         dataContext.SubmitChanges();
     }
 }
 void ILocationSaver.RemoveLocation(int locationId)
 {
     using (ManagementSystemDataContext datacontext = new ManagementSystemDataContext(_connectionString))
     {
         datacontext.Location_MasterDtos.DeleteAllOnSubmit(datacontext.Location_MasterDtos.Where(c => c.LocationId == locationId));
         datacontext.SubmitChanges();
     }
 }
 IMeetingMaster IMeetingRetriever.GetMeetingByMeetingId(int meetingId)
 {
     using (ManagementSystemDataContext dataContext = new ManagementSystemDataContext(_connectionString))
     {
         return(dataContext.Meeting_MasterDtos.SingleOrDefault(
                    c => c.MeetingId == meetingId));
     }
 }
 ILocationMaster ILocationRetriever.GetLocationByLocationId(int locationId)
 {
     using (ManagementSystemDataContext dataContext = new ManagementSystemDataContext(_connectionString))
     {
         return(dataContext.Location_MasterDtos.SingleOrDefault(
                    c => c.LocationId == locationId));
     }
 }
 int IUserRetriever.GetUserId(string userName, string password)
 {
     using (ManagementSystemDataContext dataContext = new ManagementSystemDataContext(_connectionString))
     {
         return(dataContext.UserDtos.SingleOrDefault(
                    w => w.UserName == userName &&
                    w.Password == password).UserId);
     }
 }
 List <IMeetingResponseType> IMeetingResponseTypeRetriever.GetResponseTypes()
 {
     using (ManagementSystemDataContext dataContext = new ManagementSystemDataContext(_connectionString))
     {
         IEnumerable <MeetingResponseTypeDto> meetingResponseTypes = (from types in dataContext.MeetingResponseTypeDtos
                                                                      select types);
         return(meetingResponseTypes.Cast <IMeetingResponseType>().ToList());
     }
 }
 List <IUser> IUserRetriever.GetAllUsers()
 {
     using (ManagementSystemDataContext dataContext = new ManagementSystemDataContext(_connectionString))
     {
         IEnumerable <UserDto> users = (from user in dataContext.UserDtos
                                        select user);
         return(users.Cast <IUser>().ToList());
     }
 }
 List <IMeetingMaster> IMeetingRetriever.GetAllMeetings()
 {
     using (ManagementSystemDataContext dataContext = new ManagementSystemDataContext(_connectionString))
     {
         IEnumerable <Meeting_MasterDto> meetings = (from meeting in dataContext.Meeting_MasterDtos
                                                     select meeting);
         return(meetings.Cast <IMeetingMaster>().ToList());
     }
 }
 bool IUserRetriever.IsUserValid(string userName, string password)
 {
     using (ManagementSystemDataContext dataContext = new ManagementSystemDataContext(_connectionString))
     {
         return(dataContext.UserDtos.Any(
                    w => w.UserName == userName &&
                    w.Password == password));
     }
 }
 List <IvwMeetingResponse> IMeetingRetriever.GetMeetingResponsesByMeetingId(int meetingId)
 {
     using (ManagementSystemDataContext dataContext = new ManagementSystemDataContext(_connectionString))
     {
         IEnumerable <vw_MeetingResponseDto> responses = (from response in dataContext.vw_MeetingResponseDtos
                                                          where meetingId == response.MeetingId
                                                          select response);
         return(responses.Cast <IvwMeetingResponse>().ToList());
     }
 }
        List <ILocationMaster> ILocationRetriever.GetAllLocations()
        {
            using (ManagementSystemDataContext dataContext = new ManagementSystemDataContext(_connectionString))
            {
                IEnumerable <Location_MasterDto> results = (from location in dataContext.Location_MasterDtos
                                                            select location);

                return(results.Cast <ILocationMaster>().ToList());
            }
        }
        List <IMeetingMaster> IMeetingRetriever.GetMeetingsByLocation(ILocationMaster location)
        {
            using (ManagementSystemDataContext dataContext = new ManagementSystemDataContext(_connectionString))
            {
                IEnumerable <Meeting_MasterDto> results = (from meeting in dataContext.Meeting_MasterDtos
                                                           where meeting.ActualLocationId == location.LocationId
                                                           select meeting);

                return(results.Cast <IMeetingMaster>().ToList());
            }
        }
        string IUserRetriever.GetUserFullNameByUserId(int userId)
        {
            using (ManagementSystemDataContext dataContext = new ManagementSystemDataContext(_connectionString))
            {
                string firstName = dataContext.UserDtos.SingleOrDefault(
                    u => u.UserId == userId).UserFirstName;
                string lastName = dataContext.UserDtos.SingleOrDefault(
                    u => u.UserId == userId).UserLastName;

                return(string.Concat(firstName, " ", lastName));
            }
        }
        public void SetCustomSettings(ICustomSetting customSetting)
        {
            using (ManagementSystemDataContext dataContext = new ManagementSystemDataContext(_connectionString))
            {
                CustomSettingDto customSettingDto = dataContext.CustomSettingDtos.First();
                customSettingDto.ViewDays     = customSetting.ViewDays;
                customSettingDto.WorkDayBegin = customSetting.WorkDayBegin;
                customSettingDto.WorkDayEnd   = customSetting.WorkDayEnd;

                dataContext.SubmitChanges();
            }
        }
        void IMeetingScheduler.CreateMeeting(String Desc, DateTime StartTime, DateTime EndTime, int priority
                                             , List <int> userIds, bool avRequired, bool phoneRequired
                                             , bool videoRequired, int prefLocation, int calledByUser
                                             , string myPhoneBridge, string myPhoneAccess
                                             , DateTime WindowStart, DateTime WindowEnd, int Duration)
        {
            int currentid;

            using (ManagementSystemDataContext dataContext = new ManagementSystemDataContext(_connectionString))
            {
                Meeting_MasterDto meetingMasterDto = new Meeting_MasterDto
                {
                    MeetingDesc           = Desc,
                    MeetingStartTime      = StartTime,
                    MeetingEndTime        = EndTime,
                    MeetingPriority       = priority,
                    IsAVRequired          = avRequired,
                    IsPhoneRequired       = phoneRequired,
                    IsVideoConfRequired   = videoRequired,
                    PreferredLocationId   = prefLocation,
                    ActualLocationId      = prefLocation,
                    MeetingCalledBy       = calledByUser,
                    PhoneBridge           = myPhoneBridge,
                    PhoneBridgeAccessCode = myPhoneAccess,
                    MeetingWindowStart    = WindowStart,
                    MeetingWindowEnd      = WindowEnd,
                    MeetingDuration       = Duration
                };

                dataContext.Meeting_MasterDtos.InsertOnSubmit(meetingMasterDto);
                dataContext.SubmitChanges();

                currentid = meetingMasterDto.MeetingId;
                List <Meeting_ResponseDto> meetingResponses = new List <Meeting_ResponseDto>();
                foreach (int usr in userIds)
                {
                    Meeting_ResponseDto meetingResponseDto = new Meeting_ResponseDto
                    {
                        MeetingId   = currentid,
                        FKUserId    = usr,
                        InvitedOn   = DateTime.Now,
                        RespondedOn = null
                    };

                    meetingResponses.Add(meetingResponseDto);
                }


                dataContext.Meeting_ResponseDtos.InsertAllOnSubmit <Meeting_ResponseDto>(meetingResponses);
                dataContext.SubmitChanges();
            }
        }
        List <IUserSchedule> IUserRetriever.GetUserSchedule(int userId)
        {
            List <IUserSchedule> userSchedule = new List <IUserSchedule>();

            using (ManagementSystemDataContext dataContext = new ManagementSystemDataContext(_connectionString))
            {
                userSchedule = (from schedule in dataContext.UserScheduleDtos
                                where schedule.UserId == userId
                                select schedule).Cast <IUserSchedule>().ToList();
            }

            return(userSchedule);
        }
 List <ILocationMaster> ILocationRetriever.GetLocationsFromSearchCriteria(IUser user, bool isAvRequired, bool isPhoneRequired, bool isVideoConfRequired, int capacity)
 {
     using (ManagementSystemDataContext dataContext = new ManagementSystemDataContext(_connectionString))
     {
         IEnumerable <Location_MasterDto> results = (from location in dataContext.Location_MasterDtos
                                                     where isAvRequired == location.IsAVAvailable &&
                                                     isPhoneRequired == location.IsPhoneAvailable &&
                                                     isVideoConfRequired == location.IsVideoConfAvailable &&
                                                     capacity <= location.LocationCapacity
                                                     select location);
         return(results.Cast <ILocationMaster>().ToList());
     }
 }
        List <IUserSchedule> IUserRetriever.GetUserSchedules(List <int> userIds)
        {
            List <IUserSchedule> userSchedules = new List <IUserSchedule>();

            using (ManagementSystemDataContext dataContext = new ManagementSystemDataContext(_connectionString))
            {
                foreach (int id in userIds)
                {
                    UserScheduleDto userScheduleDto = dataContext.UserScheduleDtos.SingleOrDefault(
                        c => c.UserId == id);
                    userSchedules.Add(userScheduleDto);
                }
            }

            return(userSchedules);
        }
        void IMeetingScheduler.ScheduleUserBusyTime(string description, DateTime beginTime, DateTime endTime, int userId)
        {
            using (ManagementSystemDataContext dataContext = new ManagementSystemDataContext(_connectionString))
            {
                UserScheduleDto userScheduleDto = new UserScheduleDto
                {
                    FromTime = beginTime,
                    ToTime   = endTime,
                    UserId   = userId,
                    ScheduleEntryDescription = description,
                    ScheduleEntryType        = 1
                };

                dataContext.UserScheduleDtos.InsertOnSubmit(userScheduleDto);
                dataContext.SubmitChanges();
            }
        }
        void ILocationSaver.SaveLocation(ILocationMaster location)
        {
            using (ManagementSystemDataContext datacontext = new ManagementSystemDataContext(_connectionString))
            {
                if (datacontext.Location_MasterDtos.Any(c => c.LocationId == location.LocationId))
                {
                    Location_MasterDto lcm = datacontext.Location_MasterDtos.Single(c => c.LocationId == location.LocationId);
                    lcm.IsAVAvailable        = location.IsAvAvailable;
                    lcm.IsPhoneAvailable     = location.IsPhoneAvailable;
                    lcm.IsVideoConfAvailable = location.IsVideoConfAvailable;
                    lcm.LocationBuilding     = location.LocationBuilding;
                    lcm.LocationCapacity     = location.LocationCapacity;
                    lcm.LocationFloor        = location.LocationFloor;
                    lcm.LocationName         = location.LocationName;
                    lcm.LocationRoom         = location.LocationRoom;
                }
                else
                {
                    Location_MasterDto lcm = new Location_MasterDto
                    {
                        IsAVAvailable        = location.IsAvAvailable,
                        IsPhoneAvailable     = location.IsPhoneAvailable,
                        IsVideoConfAvailable = location.IsVideoConfAvailable,
                        LocationBuilding     = location.LocationBuilding,
                        LocationCapacity     = location.LocationCapacity,
                        LocationFloor        = location.LocationFloor,
                        LocationName         = location.LocationName,
                        LocationRoom         = location.LocationRoom
                    };

                    datacontext.Location_MasterDtos.InsertOnSubmit(lcm);
                }

                datacontext.SubmitChanges();
            }
        }