public async Task <ActionResult> Post([FromBody] ProvinceCreationDTO provinceCreation) { var province = mapper.Map <Province>(provinceCreation); context.Provinces.Add(province); await context.SaveChangesAsync(); return(new CreatedAtRouteResult("GetProvince", new { id = province.Id }, province)); }
public async Task <ActionResult> Put([FromBody] ProvinceCreationDTO provinceCreation, int id) { var province = await context.Provinces.FirstOrDefaultAsync(x => x.Id == id); if (province == null) { return(NotFound()); } province = mapper.Map(provinceCreation, province); province.Id = id; await context.SaveChangesAsync(); return(NoContent()); }