Exemplo n.º 1
0
        public async Task <IActionResult> PutStudyDomain(Guid id, StudyDomainDTO studyDomain)
        {
            if (id != studyDomain.Id)
            {
                return(BadRequest());
            }

            var domain = courseMapper.MapStudyDomainDTO(studyDomain);

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

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

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <ActionResult <StudyDomainDTO> > PostStudyDomain(StudyDomainDTO studyDomain)
        {
            var domain = courseMapper.MapStudyDomainDTO(studyDomain);

            _context.StudyDomains.Add(domain);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetStudyDomain",
                                   new { id = domain.Id },
                                   courseMapper.MapStudyDomain(domain)
                                   ));
        }
Exemplo n.º 3
0
        public StudyDomain MapStudyDomainDTO(StudyDomainDTO dto)
        {
            if (dto == null)
            {
                throw new ArgumentNullException(nameof(dto));
            }

            return(new StudyDomain {
                Id = dto.Id ?? Guid.Empty,
                Name = dto.Name
            });
        }