public async Task <IActionResult> Post([FromBody] DotThuDTO model) { using (var context = new UserProfileDbContext()) { context.DotThus.Add(new DotThu { Id = model.Id, TenDotThu = model.TenDotThu }); //context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[UserProfiles] ON"); return(Ok(await context.SaveChangesAsync())); } }
public async Task <IActionResult> Put(int id, [FromBody] DotThuDTO model) { using (var context = new UserProfileDbContext()) { var user = await context.DotThus.FirstOrDefaultAsync(x => x.Id.Equals(id)); if (user == null) { return(NotFound()); } user.Id = model.Id; user.TenDotThu = model.TenDotThu; return(Ok(await context.SaveChangesAsync())); } }