public ActionResult Checkout()
        {
            if (Session["LoggedIn"] != null)
            {
                if ((bool)Session["LoggedIn"])
                {
                    var ch = new CookieHandler();

                    var Email = (string)Session["Email"];
                    var pidList = ch.GetCartProductIds();
                    var productModelList = Services.Products.GetAll(pidList);

                    var cart = productModelList.Select(p => new CartItem()
                    {
                        ProductId = p.Id,
                        Name = p.Name,
                        Count = ch.GetCount(p.Id),
                        Price = p.Price
                    }).ToList();

                    var customerModel = new AccountBLL().GetCustomer(Email);
                    var customer = new CustomerView()
                    {
                        Firstname = customerModel.Firstname,
                        Lastname = customerModel.Lastname,
                        Address = customerModel.Address,
                        Zipcode = customerModel.Zipcode,
                        City = customerModel.City,
                        Id = customerModel.CustomerId,
                        Email = customerModel.Email

                    };

                    ViewBag.Cart = cart;
                    ViewBag.Customer = customer;
                    ViewBag.LoggedIn = LoginStatus();

                    return View();
                }
            }
            return RedirectToAction("Index", "Home");
        }
        public PartialViewResult CustomerlistPartial()
        {
            var customerViewList = new List<CustomerView>();
                var customerModels = _adminBLL.GetAllCustomers();

                foreach (var Customer in customerModels)
                {
                    var customerView = new CustomerView()
                    {
                        CustomerId = Customer.CustomerId,
                        Email = Customer.Email,
                        Firstname = Customer.Firstname,
                        Lastname = Customer.Lastname,
                        Address = Customer.Address,
                        Zipcode = Customer.Zipcode,
                        City = Customer.City
                    };

                    customerViewList.Add(customerView);
                }

                return PartialView(customerViewList);
        }
        public bool UpdateCustomerInfo(CustomerView customerEdit)
        {
            var email = customerEdit.Email;

            var personUpdate = new PersonModel()
            {
                Firstname = customerEdit.Firstname,
                Lastname = customerEdit.Lastname,
                Address = customerEdit.Address,
                Zipcode = customerEdit.Zipcode,
                City = customerEdit.City
            };

            return _adminBLL.UpdatePerson(personUpdate, email);
        }
        public ActionResult ShowCustomer(int CustomerId, string ReturnUrl)
        {
            if ((Session["Admin"] == null ? false : (bool)Session["Admin"]))
            {
                var customerModel = _adminBLL.GetCustomer(CustomerId);

                var customerView = new CustomerView()
                {
                    CustomerId = customerModel.CustomerId,
                    Email = customerModel.Email,
                    Firstname = customerModel.Firstname,
                    Lastname = customerModel.Lastname,
                    Address = customerModel.Address,
                    Zipcode = customerModel.Zipcode,
                    City = customerModel.City
                };

                ViewBag.Customer = customerView;
                ViewBag.ReturnUrl = ReturnUrl;

                return View("Administration_Customer");

            }
            return RedirectToAction("Index", "Home");
        }
        public ActionResult MyPage()
        {
            if (!LoginStatus())
            {
                return RedirectToAction("Index", "Home");
            }

            string Email = (string)Session["Email"];
            var Customer = _accountBLL.GetCustomer(Email);
            var customerView = new CustomerView()
            {
                Id= Customer.CustomerId,
                Email = Customer.Email,
                Firstname = Customer.Firstname,
                Lastname = Customer.Lastname,
                Address = Customer.Address,
                Zipcode = Customer.Zipcode,
                City = Customer.City
            };

            var orders = Customer.Orders;
            var customerOrders = new List<OrderView>();

            foreach (var o in orders)
            {
                var order = new OrderView();
                order.Date = o.Date;
                order.OrderId = o.OrderId;
                order.Orderlines = new List<OrderlineView>();

                foreach(var l in o.Orderlines)
                {
                    var orderline = new OrderlineView();
                    orderline.Count = l.Count;
                    orderline.OrderlineId = l.OrderlineId;
                    orderline.Product = new ProductView()
                    {
                        Price = l.ProductPrice,
                        Id = l.ProductId,
                        Name = l.ProductName
                    };

                    order.Orderlines.Add(orderline);
                }
                customerOrders.Add(order);
            }

            //var customerOrders = Customer.Orders.Select(o => new OrderView()
            //{
            //    OrderId = o.OrderId,
            //    Orderlines = o.Orderlines.Select(l => new OrderlineView()
            //    {
            //        OrderlineId = l.OrderlineId,
            //        Count = l.Count,
            //        Product = new ProductView()
            //        {
            //            ProductId = l.ProductId,
            //            ProductName = l.ProductName,
            //            Price = l.ProductPrice
            //        }
            //    }).ToList()
            //}).ToList();

            ViewBag.LoggedIn = LoginStatus();
            ViewBag.Customer = customerView;
            ViewBag.CustomerOrders = customerOrders;

            return View();
        }
        public ActionResult UpdatePersonData(CustomerView customerEdit, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                var email = customerEdit.Email;

                var personUpdate = new Person()
                {
                    Firstname = customerEdit.Firstname,
                    Lastname = customerEdit.Lastname,
                    Address = customerEdit.Address,
                    Postal = new Postal
                    {
                        Zipcode = customerEdit.Zipcode,
                        City = customerEdit.City
                    }
                };

                if (_accountBLL.UpdatePerson(personUpdate, email))
                {
                    return RedirectToAction("MyPage");
                }
            }
            return Redirect(returnUrl);
        }
        public bool UpdateCustomerInfo(CustomerView customerEdit, string returnUrl)
        {
            var email = (string)Session["Email"];

            var personUpdate = new Person()
            {
                Firstname = customerEdit.Firstname,
                Lastname = customerEdit.Lastname,
                Address = customerEdit.Address,
                Postal = new Postal
                {
                    Zipcode = customerEdit.Zipcode,
                    City = customerEdit.City
                }
            };

            return _accountBLL.UpdatePerson(personUpdate, email);
        }