// // GET: /Item/ public ActionResult Index(int? page, int typeId = 0) { DataEntities db = new DataEntities(); var pageNumber = page ?? 1; var itemsPerPage = 9; var items = db.Items.OrderByDescending(i => i.ItemId); if (typeId != 0) { var selectedType = db.Types.Find(typeId); if (selectedType != null) { items = db.Items.Where(i => i.TypeId == typeId).OrderByDescending(i => i.ItemId); } else { return View("Error"); } } var itemsToDisplay = items.ToPagedList(pageNumber, itemsPerPage); var itemModel = new ItemIndexModel { TypeName = db.Types.Find(typeId) != null ? db.Types.Find(typeId).Name : "All", Items = itemsToDisplay }; return View(itemModel); }
public ActionResult Usage() { ItemIndexModel model = new ItemIndexModel(); model.HotelItemsList = _itemService.GetAll().Where(x => x.IsActive.Value).ToList(); return(View(model)); }
public async Task IndexItemAsync(Item item, CancellationToken cancellationToken) { if (item == null) { throw new ArgumentNullException("item"); } var node = new Uri(_config.ElasticsearchNode); var indexModel = new ItemIndexModel(item); using (var content = new StringContent(indexModel.ToJson())) using (var client = new HttpClient { BaseAddress = node }) using (var response = await client.PutAsync( string.Format("/{0}/{1}/{2}", _config.ElasticsearchIndex, item.Type.ToString().ToLower(), item.Id), content, cancellationToken).ConfigureAwait(false)) { response.EnsureSuccessStatusCode(); } const string sql = @" INSERT INTO [dbo].[ItemIndexCreatedLogs] ( [ItemId], [IndexCreatedDateTime], [RevisionNo] ) VALUES ( @ItemId, @IndexCreatedDateTime, @RevisionNo ) "; using (var cn = CreateConnection()) { await cn.OpenAsync(cancellationToken).ConfigureAwait(false); await cn.ExecuteAsync(sql, new { ItemId = item.Id, IndexCreatedDateTime = DateTime.Now, item.RevisionNo }) .ConfigureAwait(false); } }
public IActionResult Index(string category) { var items = _item.Items().Select(i => new ItemListingModel { ItemId = i.ItemId, Name = i.Name, Description = i.Description, ShortDescription = i.ShortDescription, Category = i.Category, ImageUrl = i.ImageUrl, CategoryId = i.CategoryId, InStock = i.InStock, IsSpecialOffer = i.IsSpecialOffer, Price = i.Price }); var model = new ItemIndexModel(); ViewBag.CatName = category; if (category == null) { model = new ItemIndexModel { Items = items, Categories = _category.Categories() }; } else { model = new ItemIndexModel { Items = items.Where(c => c.Category.CategoryName == category), Categories = _category.Categories() }; } return(View(model)); }
public ActionResult Inventory() { ItemIndexModel model = new ItemIndexModel(); model.StoreItems = _storeItemService.GetAll().ToList(); var modelledItemList = model.StoreItems.Where(x => !x.Usage).Select(x => new ItemInventoryModel { ItemId = x.ItemId, ItemName = x.StockItemHotel.Name, Quantity = x.Quantity, QuantityUsed = 0 }).ToList(); var modelledItemListUsed = model.StoreItems.Where(x => x.Usage).Select(x => new ItemInventoryModel { ItemId = x.ItemId, ItemName = x.StockItemHotel.Name, Quantity = 0, QuantityUsed = x.Quantity }).ToList(); modelledItemList.AddRange(modelledItemListUsed); model.ModelledItemList = modelledItemList.GroupBy(x => x.ItemName).Select(x => new ItemInventoryGroupModel { Name = x.Key, Remaining = (x.Sum(y => y.Quantity) - x.Sum(y => y.QuantityUsed)), Delivered = x.Sum(y => y.Quantity), ItemUsage = x.Sum(y => y.QuantityUsed) }).ToList(); return(View(model)); }
public IActionResult Index() { var assetItems = _assets.GetAll(); var resultList = assetItems.Select(result => new ItemListingModel { Id = result.Id, ImageUrl = result.ImageUrl, Title = result.Title, Category = result.Category.Name, Sku = result.Sku, Location = result.Location, Available = result.Available, Notes = result.Notes }); var assetModel = new ItemIndexModel() { Items = resultList }; return(View(assetModel)); }