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