Exemplo n.º 1
0
 public async Task <IActionResult> Post([FromBody] ProjectRelease release)
 {
     return(await FunctionWrapper.ExecuteFunction(this, async() =>
     {
         return await _projectRepository.Add(release);
     }));
 }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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);
     }));
 }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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;
            }
        }