public async Task <IActionResult> UpdateBasic(int id, [FromBody] Basic model) { if (model == null) { return(Ok(new ConsumptionResponse() { success = false, message = "Update data error" })); } try { var dbmodel = await repository.GetBasicByIdAsync(id); if (dbmodel == null) { return(Ok(new ConsumptionResponse() { success = false, message = "The basic was not found!" })); } dbmodel.NativeName = model.NativeName; dbmodel.EnglishName = model.EnglishName; dbmodel.LastUpdate = model.LastUpdate; dbmodel.DataCode = model.DataCode; dbmodel.LastUpdateBy = model.LastUpdateBy; repository.UpdateModelAsync(dbmodel); if (!await work.SaveChangedAsync()) { return(Ok(new ConsumptionResponse() { success = false, message = $"update post {id} failed when saving." })); } return(Ok(new ConsumptionResponse() { success = true })); } catch (Exception ex) { logger.LogDebug(ex, ""); return(Ok(new ConsumptionResponse() { success = false, message = "Update basic error" })); } }