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