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