コード例 #1
0
 public async Task <IActionResult> Post([FromBody] ProjectRelease release)
 {
     return(await FunctionWrapper.ExecuteFunction(this, async() =>
     {
         return await _projectRepository.Add(release);
     }));
 }
コード例 #2
0
        public async Task <ProjectRelease> Add(ProjectRelease release)
        {
            try
            {
                if (string.IsNullOrEmpty(release.Name))
                {
                    throw new ApplicationException("Name is required.");
                }

                var searchResult = await Search(new ProjectReleaseSearchRequest()
                {
                    Name = release.Name
                });

                if (searchResult.Count() > 0)
                {
                    throw new ApplicationException("A release with that name already exists.");
                }

                await _context.Releases.InsertOneAsync(release);

                return(await Get(release.Id));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
 public async Task <IActionResult> Put(string id, [FromBody] ProjectRelease release)
 {
     return(await FunctionWrapper.ExecuteFunction(this, async() =>
     {
         release.Id = new ObjectId(id);
         return await _projectRepository.Update(release);
     }));
 }
コード例 #4
0
        public async Task <ProjectRelease> Update(ProjectRelease release)
        {
            try
            {
                var filter = Builders <ProjectRelease> .Filter.Eq("_id", release.Id);

                await _context.Releases.ReplaceOneAsync(filter, release);

                return(await Get(release.Id));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #5
0
        private async Task <ProjectRelease> HydrateForGet(ProjectRelease release)
        {
            try
            {
                // Hydrate Project
                if (release.ProjectId != null || release.ProjectId != ObjectId.Empty)
                {
                    release.Project = await _projectRepository.Get(release.ProjectId);
                }

                return(release);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }