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