Esempio n. 1
0
 public IActionResult Index(string watchId)
 {
     if (watchId.Length == 1)
     {
         WatchVM = new WatchViewModel(DB.Watches.Where(watch => watch.Id.Equals(int.Parse(watchId))).First());
         WatchCreation.InitWatch(WatchVM.Watch);
         WatchVM.GenerateSelectedItemIds();
         return(View(WatchVM));
     }
     else
     {
         var ids = watchId.Split("-");
         WatchVM = new WatchViewModel(DB.Watches.Where(watch => watch.Id.Equals(int.Parse(ids[0]))).First());
         WatchCreation.InitBuiltWatch(WatchVM.Watch, ids);
         WatchVM.GenerateSelectedItemIds();
         return(View(WatchVM));
     }
 }
Esempio n. 2
0
        public RedirectToActionResult AddToCart(string productId, string returnUrl)
        {
            var   ids     = productId.Split("-");
            Watch product = dataContext.Watches
                            .FirstOrDefault(p => p.Id == int.Parse(ids[0]));

            creator.InitBuiltWatch(product, ids);
            if (product != null)
            {
                cart.AddItem(new SerializableWatchModel()
                {
                    Id             = product.Id, Name = product.Name,
                    Description    = product.Description, Price = product.Price,
                    WatchImagePath = product.WatchImagePath
                }, 1);
            }
            Console.WriteLine(product);
            return(RedirectToAction("Index", new { returnUrl }));
        }