Exemplo n.º 1
0
 /// <summary>
 /// Updates a project
 /// </summary>
 /// <param name="project">Project</param>
 /// <returns>Task</returns>
 public async Task UpdateProject(GoNorthProject project)
 {
     if (project.IsDefault)
     {
         await SetAllProjectsAsNonDefault();
     }
     ReplaceOneResult result = await _ProjectCollection.ReplaceOneAsync(p => p.Id == project.Id, project);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new project
        /// </summary>
        /// <param name="project">Project to create</param>
        /// <returns>Created project, with filled id</returns>
        public async Task <GoNorthProject> CreateProject(GoNorthProject project)
        {
            if (project.IsDefault)
            {
                await SetAllProjectsAsNonDefault();
            }

            project.Id = Guid.NewGuid().ToString();
            await _ProjectCollection.InsertOneAsync(project);

            return(project);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the default project
        /// </summary>
        /// <returns>Default project</returns>
        public async Task <GoNorthProject> GetDefaultProject()
        {
            GoNorthProject project = await _ProjectCollection.Find(p => p.IsDefault).FirstOrDefaultAsync();

            return(project);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets a project by it Id
        /// </summary>
        /// <param name="projectId">Project Id</param>
        /// <returns>Project</returns>
        public async Task <GoNorthProject> GetProjectById(string projectId)
        {
            GoNorthProject project = await _ProjectCollection.Find(p => p.Id == projectId).FirstOrDefaultAsync();

            return(project);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Deletes a project
 /// </summary>
 /// <param name="project">Project</param>
 /// <returns>Task</returns>
 public async Task DeleteProject(GoNorthProject project)
 {
     DeleteResult result = await _ProjectCollection.DeleteOneAsync(p => p.Id == project.Id);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Deletes a project
        /// </summary>
        /// <param name="project">Project</param>
        /// <returns>Task</returns>
        public async Task DeleteProject(GoNorthProject project)
        {
            await _UserSelectedProjectCollection.DeleteManyAsync(p => p.ProjectId == project.Id);

            DeleteResult result = await _ProjectCollection.DeleteOneAsync(p => p.Id == project.Id);
        }