public ActionResult Create(Orders order)
        {
            try
            {
                // TODO: Add insert logic here
                var stores = SRepo.GetStores().ToList();
                order.Stores = new List <Lib.Store>();

                if (order.Stores == null)
                {
                    foreach (var s in stores)
                    {
                        var tmpStore = new Lib.Store
                        {
                            Id   = s.Id,
                            Name = s.Name
                        };
                        order.Stores.Add(tmpStore);
                    }
                }

                var ord = new Lib.Order
                {
                    StoreId       = order.StoreId,
                    DatePurchased = DateTime.Now,
                    CustomerId    = order.CustomerId,
                    Total         = 0
                };

                int orderCount = ORepo.GetOrders().Count() + 2;
                int oid        = ORepo.GetOrders().Last().OrderId + 1;
                TempData["Order Id"] = oid;
                ORepo.InsertOrder(ord);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 2
0
 public static Location Map(Lib.Store store) => new Location
 {
     LocationId = store.Id,
     StoreName  = store.Name
 };