// GET: Items public ActionResult Index([FromQuery] string search = "") { List <Domain.Model.Item> items = Repo.GetItemsByName(); List <ItemViewModel> realItems = new List <ItemViewModel>(); foreach (var val in items) { realItems.Add(new ItemViewModel { ItemId = val.Id, ItemName = val.Name, ItemDescription = val.Description, ItemPrice = val.Price, StoreName = RepoStore.GetStoreById(val.StoreId).Name, OrderId = val.OrderId, SellerName = RepoSell.GetSellerById(val.SellerId).Name, TopicName = RepoTopi.GetTopicById(val.TopicId).Topic }); } if (search != null) { return(View(realItems.FindAll(p => p.ItemName.ToLower().Contains(search.ToLower()) || p.ItemDescription.ToLower().Contains(search.ToLower())))); } return(View(realItems)); }
public ActionResult Details(int id) { Domain.Model.Order order = RepoOrd.GetOrderById(id); var viewModel = new OrderViewModel { OrderId = order.Id, SortMethod = "Default", PersonName = order.Username, StoreName = RepoStore.GetStoreById(RepoPers.GetPersonById(order.UserId).StoreId).Name, OrderDate = order.Date, TotalOrderPrice = order.Price, Items = order.Items.Select(y => new ItemViewModel { ItemId = y.Id, ItemName = y.Name, ItemDescription = y.Description, ItemPrice = y.Price, StoreName = RepoStore.GetStoreById(y.StoreId).Name, OrderId = y.OrderId, SellerName = RepoSell.GetSellerById(y.SellerId).Name, TopicName = RepoTopi.GetTopicById(y.TopicId).Topic }).ToList() }; List <string> mySorters = new List <string> { "Default", "Old to New", "New to Old", "Low Price to High Price", "High Price to Low Price" }; ViewData["Sorter"] = new SelectList(mySorters); return(View(viewModel)); }
public ActionResult ViewCart(int id = 0) { double price = 0; List <Domain.Model.Item> orderItemsList = new List <Domain.Model.Item>(); foreach (var val in MyOrder.itemsInOrder) { orderItemsList.Add(RepoItem.GetItemById(val)); price = price + RepoItem.GetItemById(val).Price; } if (id > 0) { MyOrder.itemsInOrder.Add(id); orderItemsList.Add(RepoItem.GetItemById(id)); price = price + RepoItem.GetItemById(id).Price; } var viewModel = new DetailedOrderViewModel { PersonName = MyOrder.Username, StoreName = RepoStore.GetStoreById(RepoPers.GetPeopleByName(MyOrder.Username).First(p => p.Username.ToLower() == MyOrder.Username.ToLower()).StoreId).Name, DateOfOrder = DateTime.Now, Price = price, ItemList = orderItemsList, SuggestedItem = GetSuggestedItem.Suggest(RepoItem, RepoStore, RepoOrd, RepoTopi, RepoSell, RepoPers, RepoRev, MyOrder) }; return(View(viewModel)); }
public ActionResult Order([FromRoute] int id, [Bind("LogInViewModel,Items,selectedItems")] ItemAnLogInViewModel viewModel) { try { if (ModelState.IsValid) { viewModel = (ItemAnLogInViewModel )TempData["Login"]; var myOldItem = RepoItem.GetItemById(id); var myNewItem = new ItemViewModel { ItemId = myOldItem.Id, ItemName = myOldItem.Name, ItemDescription = myOldItem.Description, ItemPrice = myOldItem.Price, StoreName = RepoStore.GetStoreById(myOldItem.StoreId).Name, OrderId = myOldItem.OrderId, SellerName = RepoSell.GetSellerById(myOldItem.SellerId).Name, TopicName = RepoTopi.GetTopicById(myOldItem.TopicId).Topic }; viewModel.selectedItems.Add(myNewItem); viewModel.Items.Remove(viewModel.Items.Find(p => p.ItemId == myNewItem.ItemId)); } return(View(viewModel)); } catch { return(View(viewModel)); } }
// GET: Items/Edit/5 public IActionResult Edit(int id) { // we pass the current values into the Edit view // so that the input fields can be pre-populated instead of blank // (important for good UX) Domain.Model.Person person = RepoPers.GetPersonById(id); var viewModel = new PersonViewModel { PersonId = person.Id, FirstName = person.FirstName, LastName = person.LastName, Username = person.Username, Password = person.Password, Employee = person.EmployeeTag, StoreName = RepoStore.GetStoreById(person.StoreId).Name, }; List <string> myStores = new List <string> (); foreach (var val in RepoStore.GetStoresByName().ToList()) { myStores.Add(val.Name); } ViewData["StoreName"] = new SelectList(myStores); return(View(viewModel)); }
// GET: Items/Delete/5 public IActionResult Delete(int id) { Domain.Model.Store store = RepoStore.GetStoreById(id); var viewModel = new StoreViewModel { StoreId = store.Id, LocationName = store.Name, ItemCount = store.Items.Count }; return(View(viewModel)); }
// GET: Items/Create public IActionResult Delete(int id) { Domain.Model.Order order = RepoOrd.GetOrderById(id); var viewModel = new OrderViewModel { OrderId = order.Id, PersonName = order.Username, StoreName = RepoStore.GetStoreById(RepoPers.GetPersonById(order.UserId).StoreId).Name, OrderDate = order.Date, TotalOrderPrice = order.Price }; return(View(viewModel)); }
// GET: Items/Edit/5 public IActionResult Edit(int id) { // we pass the current values into the Edit view // so that the input fields can be pre-populated instead of blank // (important for good UX) Domain.Model.Store store = RepoStore.GetStoreById(id); var viewModel = new StoreViewModel { StoreId = store.Id, LocationName = store.Name, ItemCount = store.Items.Count }; return(View(viewModel)); }
// GET: Items/Delete/5 public IActionResult Delete(int id) { Domain.Model.Person person = RepoPers.GetPersonById(id); var viewModel = new PersonViewModel { PersonId = person.Id, FirstName = person.FirstName, LastName = person.LastName, Username = person.Username, Password = person.Password, Employee = person.EmployeeTag, StoreName = RepoStore.GetStoreById(person.StoreId).Name, }; return(View(viewModel)); }
// GET: Items/Delete/5 public IActionResult Delete(int id) { Domain.Model.Item item = Repo.GetItemById(id); var viewModel = new ItemViewModel { ItemId = item.Id, ItemName = item.Name, ItemDescription = item.Description, ItemPrice = item.Price, StoreName = RepoStore.GetStoreById(item.StoreId).Name, OrderId = item.OrderId, SellerName = RepoSell.GetSellerById(item.SellerId).Name, TopicName = RepoTopi.GetTopicById(item.TopicId).Topic }; return(View(viewModel)); }
// GET: Items/Edit/5 public IActionResult Edit(int id) { // we pass the current values into the Edit view // so that the input fields can be pre-populated instead of blank // (important for good UX) Domain.Model.Item item = Repo.GetItemById(id); var viewModel = new ItemViewModel { ItemId = item.Id, ItemName = item.Name, ItemDescription = item.Description, ItemPrice = item.Price, StoreName = RepoStore.GetStoreById(item.StoreId).Name, OrderId = item.OrderId, SellerName = RepoSell.GetSellerById(item.SellerId).Name, TopicName = RepoTopi.GetTopicById(item.TopicId).Topic }; List <string> mySellers = new List <string> (); foreach (var val in RepoSell.GetSellersByName().ToList()) { mySellers.Add(val.Name); } ViewData["Seller"] = new SelectList(mySellers); List <string> myTopics = new List <string> (); foreach (var val in RepoTopi.GetTopicByName().ToList()) { myTopics.Add(val.Topic); } ViewData["Topic"] = new SelectList(myTopics); List <string> myStores = new List <string> (); foreach (var val in RepoStore.GetStoresByName().ToList()) { myStores.Add(val.Name); } ViewData["Store"] = new SelectList(myStores); return(View(viewModel)); }
// GET: Items public ActionResult Index([FromQuery] string search = "") { List <Domain.Model.Order> orders = RepoOrd.GetOrdersByName(); List <OrderViewModel> realOrders = new List <OrderViewModel>(); foreach (var val in orders) { realOrders.Add(new OrderViewModel { OrderId = val.Id, PersonName = val.Username, StoreName = RepoStore.GetStoreById(RepoPers.GetPersonById(val.UserId).StoreId).Name, OrderDate = val.Date, TotalOrderPrice = val.Price }); } if (search != null) { return(View(realOrders.FindAll(p => p.PersonName.ToLower().Contains(search.ToLower()) || (RepoStore.GetStoreById(RepoPers.GetPeopleByName(p.PersonName).First().StoreId).Name.ToLower()).Contains(search.ToLower())))); } return(View(realOrders)); }
public IActionResult Edit([FromRoute] int id, [Bind("LocationName")] StoreViewModel viewModel) { try { if (ModelState.IsValid) { Domain.Model.Store store = RepoStore.GetStoreById(id); store.Name = viewModel.LocationName; store.Items = RepoItem.GetItemsByStoreName(viewModel.LocationName) .FindAll(p => p.StoreId == (RepoStore.GetStoresByName(viewModel.LocationName) .First(p => p.Name == viewModel.LocationName).Id)); RepoStore.UpdateStore(store); RepoStore.Save(); return(RedirectToAction(nameof(Index))); } return(View(viewModel)); } catch (Exception) { return(View(viewModel)); } }
// GET: Items public ActionResult Index([FromQuery] string search = "") { List <Domain.Model.Person> people = RepoPers.GetPeopleByName(); List <PersonViewModel> realPeople = new List <PersonViewModel>(); foreach (var val in people) { realPeople.Add(new PersonViewModel { PersonId = val.Id, FirstName = val.FirstName, LastName = val.LastName, Username = val.Username, Password = val.Password, Employee = val.EmployeeTag, StoreName = RepoStore.GetStoreById(val.StoreId).Name, }); } if (search != null) { return(View(realPeople.FindAll(p => p.Username.ToLower().Contains(search.ToLower())))); } return(View(realPeople)); }