public async Task <ActionResult <Market_List> > PostMarketList([FromBody] MarketListVM mlvm) { Market_List ml = new Market_List(); // ml.Market_ID = mlvm.Market_ID; ml.Market_Name = mlvm.Market_Name; ml.Market_Address = mlvm.Market_Address; ml.Post_Code = mlvm.Post_Code; ml.District = mlvm.District; ml.Country_Name = mlvm.Country_Name; db.Market_List.Add(ml); // db.Entry(ml).State = EntityState.Modified; await db.SaveChangesAsync(); return(Ok()); }
public async Task <IActionResult> PutMarketList(int id, MarketListVM mlvm) { if (id != mlvm.Market_ID) { return(BadRequest()); } Market_List ml = new Market_List(); ml.Market_ID = Convert.ToInt32(mlvm.Market_ID); ml.Market_Name = mlvm.Market_Name; ml.Market_Address = mlvm.Market_Address; ml.Post_Code = mlvm.Post_Code; ml.District = mlvm.District; ml.Country_Name = mlvm.Country_Name; db.Entry(ml).State = EntityState.Modified; await db.SaveChangesAsync(); try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Market_ListExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }