/// <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)); }
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]); }
/// <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)); }