Esempio n. 1
0
        public ActionResult AddClick(long?itemId)
        {
            MyItem itemName = new MyItem();

            HttpCookie   cookie = Request.Cookies["UserId"];
            long         longCookie;
            CookieCheker TheCheker = new CookieCheker();

            if (TheCheker.Cheker(cookie, out longCookie))
            {
                using (MyDbEntity db = new MyDbEntity())
                {
                    foreach (var itemDb in db.Items)
                    {
                        if (itemId == itemDb.ItemId)
                        {
                            itemDb.UserId = longCookie;
                        }
                    }
                    db.SaveChanges();
                }
                return(View("AddToBasket"));
            }
            return(View("NoUser"));
        }
Esempio n. 2
0
        public ActionResult Basket()
        {
            HttpCookie   cookie = Request.Cookies["UserId"];
            long         longCookie;
            CookieCheker TheCheker = new CookieCheker();

            List <Item> itemList = new List <Item>();

            if (TheCheker.Cheker(cookie, out longCookie))
            {
                using (MyDbEntity db = new MyDbEntity())
                {
                    foreach (var itemInDb in db.Items)
                    {
                        if (itemInDb.UserId == longCookie)
                        {
                            itemList.Add(itemInDb);
                        }
                    }
                }
                return(View("Basket", itemList));
                // return View("NoItemInBasket");
            }
            return(View("NoUser"));
        }
Esempio n. 3
0
        public ActionResult UpdateItem()
        {
            HttpCookie   cookie = Request.Cookies["UserId"];
            long         longCookie;
            CookieCheker TheCheker = new CookieCheker();

            if (TheCheker.Cheker(cookie, out longCookie))
            {
                return(View());
            }
            else
            {
                return(View("NoUser"));
            }
        }
Esempio n. 4
0
        public ActionResult UpdateItem(MyItem newItem)
        {
            MyUser userClass = new MyUser();
            Item   sendItem  = new Item();

            HttpCookie   cookie = Request.Cookies["UserId"];
            long         longCookie;
            CookieCheker TheCheker = new CookieCheker();

            if (TheCheker.Cheker(cookie, out longCookie))
            {
                if (ModelState.IsValid)
                {
                    Item itemInDb = new Item()
                    {
                        StatusSail = false,
                        OwnerId    = longCookie,

                        Title            = newItem.Title,
                        Price            = Convert.ToDecimal(newItem.Price),
                        ShortDescription = newItem.ShortDescription,
                        LongDescription  = newItem.LongDescription,
                        Date             = DateTime.Now,
                        PicLink1         = Converter(newItem.PicLink1),
                        PicLink2         = Converter(newItem.PicLink2),
                        PicLink3         = Converter(newItem.PicLink3)
                    };
                    sendItem = itemInDb;
                }

                using (MyDbEntity dbUpdate = new MyDbEntity())
                {
                    dbUpdate.Items.Add(sendItem);
                    dbUpdate.SaveChanges();
                }
                return(View("EndUpdateItem", newItem));
            }
            return(View("NoUser"));
        }
Esempio n. 5
0
        //public ActionResult Logout()
        //{
        //    if (Request.Cookies["StudentCookies"] != null)
        //    {
        //        HttpCookie StudentCookies = new HttpCookie("StudentCookies", userClass.UserEmail);
        //        StudentCookies.Expires = DateTime.Now.AddMinutes(-10);
        //        Response.Cookies.Add(StudentCookies);
        //    }
        //    return RedirectToAction("Index", controllerName: "Home");
        //}


        public ActionResult StatusUserBar()
        {
            HttpCookie   cookie = Request.Cookies["UserId"];
            long         longCookie;
            CookieCheker TheCheker = new CookieCheker();

            if (TheCheker.Cheker(cookie, out longCookie))
            {
                MyUser userClass = new MyUser();
                using (MyDbEntity db = new MyDbEntity())
                {
                    foreach (var userInDb in db.Users)
                    {
                        if (userInDb.UserId == longCookie)
                        {
                            userClass.UserName = userInDb.FirstName + " " + userInDb.LastName;
                        }
                    }
                    return(View("StatusUserBar", userClass));
                }
            }
            return(View("NoUserLogedIn"));
        }