Пример #1
0
        //Add/Buy to/from Cart gets and saves userdata

        public ActionResult Buy(int id)
        {
            foreach (Furnuture furnuture in furnutureList)
            {
                if (furnuture.Id == id)
                {
                    furnuture.Count--;
                    furnuture.BuyCount++;

                    Furnuture.SaveData(furnutureList);
                    userdata = UserData.GetUserData((int)Session["UserId"]);
                    if (userdata.CartList == null)
                    {
                        userdata.CartList = new List <UserData.Cart>();
                    }
                    userdata.CartList.Add(new UserData.Cart {
                        Id = furnuture.Id
                    });
                    UserData.SaveUserData(userdata);
                }
            }
            userdata = UserData.GetUserData((int)Session["UserId"]);

            ViewModel VM = ViewModel.viewmodel(furnutureList, userdata);

            return(View("Index", VM));
        }
Пример #2
0
        //delete from Cart and saves and gets
        public ActionResult Return(int id)
        {
            foreach (Furnuture furnuture in furnutureList)
            {
                if (furnuture.Id == id)
                {
                    furnuture.Count++;
                    Furnuture.SaveData(furnutureList);
                    userdata = UserData.GetUserData((int)Session["UserId"]);
                    var itemToRemove = userdata.CartList.FirstOrDefault(r => r.Id == id);
                    if (itemToRemove != null)
                    {
                        userdata.CartList.Remove(itemToRemove);
                        UserData.SaveUserData(userdata);
                    }
                }
            }

            ViewModel VM = ViewModel.viewmodel(furnutureList, userdata);

            return(View("Index", VM));
        }
Пример #3
0
        public ActionResult furnutures(int Id)
        {
            Furnuture product = furnutureList.Where(x => x.Id == Id).FirstOrDefault();

            return(View(product));
        }