public static void CreateMarketIndex(MarketIndexModel marketIndexModel) { using (ctaDBEntities entities = new ctaDBEntities()) { MarketIndex mIndex = new MarketIndex() { name = marketIndexModel.name, market_id = marketIndexModel.market_id }; entities.MarketIndexes.Add(mIndex); entities.SaveChanges(); if (!(entities.Database.Connection.State == ConnectionState.Closed)) { entities.Database.Connection.Close(); } } }
public static void UpdateMarketIndex(MarketIndexModel marketIndexModel) { using (ctaDBEntities entities = new ctaDBEntities()) { MarketIndex mIndex = entities.MarketIndexes.Where(s => s.Id == marketIndexModel.Id).FirstOrDefault(); if (mIndex != null) { mIndex.name = marketIndexModel.name; mIndex.market_id = marketIndexModel.market_id; entities.SaveChanges(); } if (!(entities.Database.Connection.State == ConnectionState.Closed)) { entities.Database.Connection.Close(); } } }
public IActionResult Index() { var markets = _marketCategoryService.GetAll(); var results = markets.Select(result => new MarketModel { MarketName = result.MarketPlaceName, AccountName = result.Account, ListingQty = _marketCategoryService.GetCount(result.Id), Items = _marketCategoryService.GetItemsForMarketCategory(result.Id).Select(item => new InventoryItemModel() { Id = item.Id, ImageUrl = item.ImageUrl, Title = item.Title }).ToList(), Notes = result.Notes }); var model = new MarketIndexModel() { Markets = results }; return(View(model)); }