예제 #1
0
        public async Task <IActionResult> PutProject(int id, DTO.Project input)
        {
            var project = await _db.Projects.FindAsync(id);

            if (project == null)
            {
                return(NotFound());
            }

            project.Title            = input.Title;
            project.Description      = input.Description;
            project.ProjectManagerId = input.ProjectManagerId;

            await _db.SaveChangesAsync();

            return(NoContent());
        }
예제 #2
0
        public async Task <ActionResult <ProjectResponse> > PostProject(DTO.Project input)
        {
            var project = new Data.Project
            {
                Title            = input.Title,
                Description      = input.Description,
                ProjectManagerId = input.ProjectManagerId
            };

            _db.Projects.Add(project);
            await _db.SaveChangesAsync();

            var result = project.MapProjectResponse();

            return(CreatedAtAction(nameof(GetProject),
                                   new { id = result.Id }, result));
        }