/// <summary> /// GET Search/Details /// See detailed information about placed orders /// </summary> /// <param name="id">Order ID</param> /// <returns></returns> public IActionResult Details(int?id) { if (id == null) { return(NotFound()); } var orderLines = _unitOfWork.Orders.GetLineItems(id.Value).ToList(); if (orderLines == null) { return(NotFound()); } Console.WriteLine(orderLines.Count()); //var lineItems = order.OrderLineItems; var detailsViewModel = new SearchDetailsViewModel { LineItems = orderLines }; return(View(detailsViewModel)); }
public async Task <IActionResult> GetDetails([FromQuery(Name = "sid")] int searchId, [FromQuery(Name = "mid")] int mortgageId) { //Register that the customer is interested in this product based on this search for potential reporting purposes var mortgage = await _searchService.RegisterMortgageOfInterest(searchId, mortgageId); var viewModel = new SearchDetailsViewModel(mortgage, searchId); return(View("Details", viewModel)); }
public async Task <IActionResult> AddToDeck(SearchDetailsViewModel model) { int deckId; if (int.TryParse(model.DeckId, out deckId)) { var card = await _DataAccess.CardDataAccess.GetCardByNameAsync(model.Name); if (card == null) { var apiCard = await _YGOProDeckAccess.GetCardByNameAsync(model.Name); if (apiCard.CardImages != null && apiCard.CardImages.Count > 0) { apiCard.ImageBytes = _YGOProDeckAccess.GetCardImage(apiCard.CardImages.First()); } card = await _DataAccess.CardDataAccess.Upsert(apiCard); } var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); // will give the user's userId if (string.IsNullOrWhiteSpace(userId)) { return(RedirectToAction("Details", model)); } var userInventory = await _DataAccess.UserInventoryDataAccess.GetUserInventoryByUserAsync(userId); var userCardMapping = _DataAccess.CardDataAccess.GetSpecificCardMappingForUserAsync(userInventory.Id, card.Id); if (userCardMapping == null) { var cardmapping = new InventoryCardMapping(); cardmapping.CardId = card.Id; cardmapping.UserInventoryId = userInventory.Id; cardmapping.Count = 1; await _DataAccess.CardDataAccess.UpsertCardMappingAsync(cardmapping); } var mapping = await _DataAccess.DeckDataAccess.GetDeckCardMappingAsync(deckId, card.Id); if (mapping != null) { mapping.Count++; await _DataAccess.DeckDataAccess.UpsertDeckCardMappingAsync(mapping); } else { mapping = new DeckCardMapping(); mapping.CardId = card.Id; mapping.DeckId = deckId; mapping.Count = 1; await _DataAccess.DeckDataAccess.UpsertDeckCardMappingAsync(mapping); } } return(RedirectToAction("Details", model)); }
public async Task <IActionResult> AddCard(string name, string query) { var model = new SearchDetailsViewModel(); model.Query = query; model.Name = name; var cardData = await _DataAccess.CardDataAccess.GetCardByNameAsync(name); if (cardData == null) { var apiCard = await _YGOProDeckAccess.GetCardByNameAsync(name); if (apiCard.CardImages != null && apiCard.CardImages.Count > 0) { apiCard.ImageBytes = _YGOProDeckAccess.GetCardImage(apiCard.CardImages.First()); } cardData = await _DataAccess.CardDataAccess.Upsert(apiCard); } var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); // will give the user's userId if (string.IsNullOrWhiteSpace(userId)) { return(RedirectToAction("Home", "Index")); } var userInventory = await _DataAccess.UserInventoryDataAccess.GetUserInventoryByUserAsync(userId); var cardmapping = await _DataAccess.CardDataAccess.GetSpecificCardMappingForUserAsync(userInventory.Id, cardData.Id); if (cardmapping != null) { cardmapping.Count++; await _DataAccess.CardDataAccess.UpsertCardMappingAsync(cardmapping); } else { cardmapping = new InventoryCardMapping(); cardmapping.CardId = cardData.Id; cardmapping.UserInventoryId = userInventory.Id; cardmapping.Count = 1; await _DataAccess.CardDataAccess.UpsertCardMappingAsync(cardmapping); } return(RedirectToAction("Details", model)); }
public async Task <IActionResult> Details(string Name, string query) { var model = new SearchDetailsViewModel(); var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); if (!string.IsNullOrWhiteSpace(userId)) { var userInventory = await _DataAccess.UserInventoryDataAccess.GetUserInventoryByUserAsync(userId); var decks = await _DataAccess.DeckDataAccess.GetDecksByUserAsync(userInventory.Id); model.Decks = decks; } model.Query = query; if (!string.IsNullOrWhiteSpace(Name)) { model.Name = Name; model.Result = await _YGOProDeckAccess.GetCardByNameAsync(Name); var card = await _DataAccess.CardDataAccess.GetCardByNameAsync(Name); if (card != null) { model.Result = card; var listings = await _DataAccess.TradeDataAccess.GetTradeListingsByCard(card.Id); if (listings != null) { var filteredListings = listings.Where(x => TradeDataAccess.IsStateDeletable(x.TradeState)).ToList(); model.Listings = filteredListings; } } } else { return(View("Index")); } if (string.IsNullOrWhiteSpace(model.Result?.Name)) { return(View("Index")); } return(View(model)); }