public object Create(DemographicDto dto)
        {
            var entity = Mapper.Map <Demographic>(dto);

            context.Add(entity);
            context.SaveChanges();
            return(entity.DemographicId);
        }
        public void Update(int id, DemographicDto dto)
        {
            var entity = context.Demographics.Find(id);

            if (entity == null)
            {
                throw new NotFoundException();
            }

            context.Update(Mapper.Map(dto, entity));
            context.SaveChanges();
        }
Exemple #3
0
 public IActionResult Put(int id, [FromBody] DemographicDto dto)
 {
     DemographicService.Update(id, dto);
     return(Ok());
 }
Exemple #4
0
 public IActionResult Post([FromBody] DemographicDto dto)
 {
     return(Ok(new { id = DemographicService.Create(dto) }));
 }