コード例 #1
0
ファイル: DataProvider.cs プロジェクト: rossmcewan/indoorworx
        /// <summary>
        /// Get the projects collection of the given user.
        /// </summary>
        /// <param name="userName">The name of the user.</param>
        /// <returns>A <see cref="ProjectCollection"/> with all the projects of the user.</returns>
        public ProjectCollection GetProjectsByUser(string userName)
        {
            RoughCutEditorEntities context = new RoughCutEditorEntities();

            List <Project> projects = context.Project
                                      .Include("MediaBin")
                                      .Where(x => x.Creator == userName)
                                      .ToList();

            return(SqlDataProviderTranslator.ConvertToProjects(projects));
        }
コード例 #2
0
        public void ShouldConvertListOfSqlProjectsToProjectCollection()
        {
            var sqlProjects = new List <SqlProject>();

            sqlProjects.Add(SqlHelper.CreateSqlProject());
            sqlProjects.Add(SqlHelper.CreateSqlProject());

            var projects = SqlDataProviderTranslator.ConvertToProjects(sqlProjects);

            SqlHelper.AssertProject(sqlProjects[0], projects[0]);
            SqlHelper.AssertProject(sqlProjects[1], projects[1]);
        }
コード例 #3
0
        /// <summary>
        /// Get the projects collection of the given user.
        /// </summary>
        /// <param name="userName">The name of the user.</param>
        /// <returns>A <see cref="ProjectCollection"/> with all the projects of the user.</returns>
        public ProjectCollection GetProjectsByUser(string userName)
        {
            RoughCutEditorEntities context  = default(RoughCutEditorEntities);
            List <Project>         projects = default(List <Project>);

            try
            {
                context = new RoughCutEditorEntities();

                projects = context.Project.Include("MediaBin").Where(x => x.Creator == userName).ToList();
            }
            finally
            {
                if (context != null)
                {
                    context.Dispose();
                }
            }

            return(SqlDataProviderTranslator.ConvertToProjects(projects, this.metadataLocator));
        }