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