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(); }
public IActionResult Put(int id, [FromBody] DemographicDto dto) { DemographicService.Update(id, dto); return(Ok()); }
public IActionResult Post([FromBody] DemographicDto dto) { return(Ok(new { id = DemographicService.Create(dto) })); }