public async Task <IActionResult> PostProject([FromBody] ProjectDTO dto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var project     = ProjectDTO.UpdateDbObjectWithDTO(new Project(), dto);
            var currentUser = await GetCurrentUserAsync();

            project.OwnerId = currentUser.Id;

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

            return(CreatedAtAction("GetProject", new { id = project.Id }, project));
        }
        public async Task <IActionResult> PutProject([FromRoute] int id, [FromBody] ProjectDTO dto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != dto.Id)
            {
                return(BadRequest());
            }

            var project = await _context.Projects.SingleOrDefaultAsync(x => x.Id == dto.Id);

            try
            {
                await EnsureAuthorizedAccessAsync(project);
            }
            catch (Exception)
            {
                return(Unauthorized());
            }

            project = ProjectDTO.UpdateDbObjectWithDTO(project, dto);

            _context.Entry(project).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProjectExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }