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