示例#1
0
        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));
        }
示例#2
0
 public ActionResult Finalize()
 {
     try
     {
         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;
         }
         Domain.Model.Order myNewOrder = new Domain.Model.Order
         {
             UserId = RepoPers.GetPeopleByName(MyOrder.Username).First().Id,
             Date   = DateTime.Now,
             Price  = price,
             Items  = orderItemsList
         };
         RepoOrd.AddOrder(myNewOrder);
         RepoOrd.Save();
         MyOrder.Username     = "";
         MyOrder.itemsInOrder = null;
     }
     catch
     {
         return(RedirectToAction("Index", "Home"));
     }
     return(RedirectToAction("Index", "Home"));
 }
示例#3
0
        // 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));
        }
示例#4
0
        public ActionResult Delete(int id, [BindNever] IFormCollection collection)
        {
            try
            {
                RepoItem.DeleteItemByOrderId(id);
                RepoOrd.DeleteOrderById(id);
                RepoOrd.Save();

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
示例#5
0
        // 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));
        }