Example #1
0
        private IQueryable <User> getAllUsers()
        {
            var user = this.GetUser(CurrentUser.GetUserName());

            if (user == null)
            {
                return(null);
            }

            var userId       = user.UserId;
            var OfficeTypeId = user.Office.OfficeTypeId;
            var offices      = new OfficeRepository().GetOfficesByProv(user.Office.ProvinceId).ToIds();

            if (OfficeTypeId == (int)OfficeTypes.HEADOFFICE)
            {
                return(from u in this.m_Context.Users
                       where u.UserId != userId
                       orderby u.UserName
                       select u);
            }
            else
            {
                return(from u in this.m_Context.Users
                       where u.UserId != userId &&
                       offices.Any(new Func <int, bool>(i => i == u.OfficeId))
                       orderby u.UserName
                       select u);
            }
        }
        private IQueryable <Driver> getAllDrivers()
        {
            var user = new UserRepository().GetUser(CurrentUser.GetUserName());

            if (user == null)
            {
                return(null);
            }

            var userId       = user.UserId;
            var OfficeTypeId = user.Office.OfficeTypeId;
            var offices      = new OfficeRepository().GetOfficesByProv(user.Office.ProvinceId).ToIds();

            if (OfficeTypeId == (int)OfficeTypes.HEADOFFICE)
            {
                return(from v in this.m_Context.Drivers
                       orderby v.FirstName, v.Surname
                       select v);
            }
            else
            {
                return(from v in this.m_Context.Drivers
                       // where offices.Any(new Func<int, bool>(i => i == v.OfficeId))
                       orderby v.FirstName, v.Surname
                       select v);
            }
        }