Ejemplo n.º 1
0
        public void CreateUser(String name, String password, String email)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("username");
            }
            if (String.IsNullOrEmpty(password))
            {
                throw new ArgumentNullException("password");
            }
            if (String.IsNullOrEmpty(email))
            {
                throw new ArgumentNullException("email");
            }
            if ((from c in this.Database.Customers where c.Email.ToLower() == email.ToLower() select c).SingleOrDefault()!=null)
            {
                throw new Exception("Email already exists");

            }

            Customer customer = new Customer();
            customer.Name = name;
            customer.Password = password;
            customer.Email = email;

            this.Database.Customers.InsertOnSubmit(customer);
            this.Database.SubmitChanges();
        }
Ejemplo n.º 2
0
        public Cart(Service service, Customer customer, Basket basket)
        {
            this.service = service;
            this.customer = customer;
            this.basket = basket;

            addShoppingList(basket);
        }
Ejemplo n.º 3
0
 public void LogoutUser()
 {
     customer = null;
     gui.ToggleMenus(IsUserLoggedIn());
     gui.ClearList();
 }
Ejemplo n.º 4
0
        private void LoginUser(String tag)
        {
            customer = service.GetCustomerByTag(tag);

            if (IsUserLoggedIn())
            {
                gui.ToggleMenus(IsUserLoggedIn());
                Basket basket = service.GetShoppingListForCustomer(customer.Id);
                if (customer.ShoppingListBasketId != null)
                {
                    basket.BasketProducts = service.GetBasketProducts((int)customer.ShoppingListBasketId);
                }

                cart = new Cart(service, customer, basket);

                gui.DisplayMessage("Welkom: " + customer.Name);
            }
        }