public async Task<IHttpActionResult> PostProduct(TradeShows TradeShows) { if (ModelState.IsValid) { await Repository.SaveTradshowAsync(TradeShows); return Ok(); } else { return BadRequest(ModelState); } }
public async Task<int> SaveTradshowAsync(TradeShows TradeShows) { if (TradeShows.Id == 0) { context.TradeShows.Add(TradeShows); } else { TradeShows dbEntry = context.TradeShows.Find(TradeShows.Id); if (dbEntry != null) { dbEntry.TradeShowName = TradeShows.TradeShowName; dbEntry.LeadName = TradeShows.LeadName; dbEntry.EmailAddress = TradeShows.EmailAddress; dbEntry.Telepohone = TradeShows.Telepohone; } } return await context.SaveChangesAsync(); }
public async Task<ActionResult> SaveTradeShow(TradeShows TradeShow) { await repo.SaveTradshowAsync(TradeShow); return RedirectToAction("Index"); }