예제 #1
0
 public ActionResult CustomerLogin(string Email, string Password)
 {
     if (!Request.IsAuthenticated)
     {
         bool whatevs = false;
         WebCustomerService webCustomerService = new WebCustomerService();
         whatevs = webCustomerService.LoginCustomer(Email, Password);
         WebCustomer webCustomer = new WebCustomer();
         Session["FirstName"] = webCustomer.FirstName;
         if (whatevs == true)
         {
             /*HttpContext.GetOwinContext().Authentication.Challenge(
              * new AuthenticationProperties { RedirectUri = "/" },
              *  OpenIdConnectAuthenticationDefaults.AuthenticationType
              * );*/
             string FirstName = Guid.NewGuid().ToString();
             Session["FirstName"] = FirstName;
             var cookie = new HttpCookie("FirstName");
             cookie.Value = FirstName;
             Response.Cookies.Add(cookie);
             //FormsAuthentication.SetAuthCookie(webCustomer.Email, true);
             return(RedirectToAction("Index", "Home"));
         }
         return(Private());
     }
     else
     {
         ModelState.AddModelError("", "Wrong email and/or password");
         return(RedirectToAction("CustomerLogin"));
     }
 }
예제 #2
0
        public ActionResult CreateCustomer(string firstName, string lastName, string address, string email, string password)
        {
            bool        createdAccount = false;
            WebCustomer webCustomer    = new WebCustomer
            {
                FirstName = firstName,
                LastName  = lastName,
                Address   = address,
                Email     = email,
                Password  = password,
            };
            WebCustomerService webCustomerService = new WebCustomerService();

            createdAccount = webCustomerService.CreateCustomerAccount(webCustomer);
            if (createdAccount == true)
            {
                //return View();
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ModelState.AddModelError("", "Email already in use.");
                return(RedirectToAction("CreateCustomerAccount", "Home"));
            }
        }
예제 #3
0
        public static void AddToNewsletter(Newsletter item)
        {
            List <int> ListIDs = new List <int>();

            ListIDs.Add(103435);
            string ClientUser     = "******";
            string ClientPassword = "******";

            try
            {
                CustomerServiceSoapClient client = new CustomerServiceSoapClient();
                AuthHeader authHeader            = new AuthHeader();
                authHeader.Username = ClientUser;
                authHeader.Password = ClientPassword;
                authHeader.Token    = client.Login(authHeader);


                WebCustomer customer = new WebCustomer();
                customer.Email     = item.NewsletterEmail;
                customer.FirstName = item.NewsletterName;
                customer.Phone1    = item.NewsletterPhone;

                APIResponse response = client.ImportCustomer(authHeader, customer, ListIDs.ToArray(), new int[0]);
            }
            catch (Exception ex)
            {
                SF.LogError(ex);
            }
        }
예제 #4
0
 private void SetCustomer(string imei)
 {
     try
     {
         WebCustomer.Customer = WebCustomer.GetByImei(imei);
     }
     catch (Exception ex)
     {
         WebErrorLog.ErrorInstence.StartErrorLog(ex);
         WebCustomer.Customer = null;
     }
 }
예제 #5
0
 private void FailedToServe(WebCustomer customer)
 {
     Clients.All.failedToServe(customer.Id);
 }
예제 #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome ABC Ecomm Store!!\nWe have following products in store.\n");

            Thread.Sleep(2000);

            var allProducts = ECommData.GetAllProducts();

            ECommData.DisplayProductsInStore(allProducts);

            /*
             *
             * WebCustomer webCustomer = new WebCustomer();
             *
             * //Must Login First
             * webCustomer.LogIn();
             * ContinueShopping:
             * System.Threading.Thread.Sleep(2000);
             * Console.WriteLine("Enter Product Name and Quantity to Add to Your Cart");
             * var itemName = Console.ReadLine();
             * var quantity = Console.ReadLine();
             * var product = allProducts.FirstOrDefault(x => x.ProductName.ToUpper() == itemName.ToUpper());
             * if (product != null)
             *  webCustomer.AddProductInCart(product, int.Parse(quantity));
             *
             * Console.WriteLine("Still shopping? Y/N");
             *
             * var response = Console.ReadLine();
             *
             * if (response.ToUpper() == "Y")
             *  goto ContinueShopping;
             *
             * webCustomer.CalculateTotal();
             *
             */


            //If Customer is Premium customer, should I repeat above code again??
            //NO

            //ToDo: Use below code

            Console.WriteLine("");
            Console.WriteLine("Enter 'P' for premium customer or enter any other key for web customer");
            var customerType = Console.ReadLine();

            BaseCustomer customer;

            if (customerType.ToUpper() == "P")
            {
                customer       = new PremiumCustomer();
                customer.Name  = "John Smith";
                customer.Email = "*****@*****.**";
                customer.Id    = 1015;
            }
            else
            {
                customer       = new WebCustomer();
                customer.Name  = "John Smith";
                customer.Email = "*****@*****.**";
                customer.Id    = 1015;
            }


            //Must Login First
            customer.LogIn();
ContinueShopping:
            System.Threading.Thread.Sleep(2000);
            Console.WriteLine("Enter Product Name and Quantity to Add to Your Cart");
            var itemName = Console.ReadLine();
            var quantity = Console.ReadLine();
            var product  = allProducts.FirstOrDefault(x => x.ProductName.ToUpper() == itemName.ToUpper());

            if (product != null)
            {
                customer.AddProductInCart(product, int.Parse(quantity));
            }

            Console.WriteLine("Still shopping? Y/N");

            var response = Console.ReadLine();

            if (response.ToUpper() == "Y")
            {
                goto ContinueShopping;
            }

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("\nItems in your cart\n");
            Console.ForegroundColor = ConsoleColor.White;
            customer.ViewAllCartProducts();
            Console.WriteLine("");
            decimal totalToPay = customer.CalculateTotal();

            Console.WriteLine($"You need to pay {totalToPay}");

            customer.MakePayment(totalToPay);

            Thread.Sleep(1500);
            Console.WriteLine("Cheking customer's rewards.\n");

            Thread.Sleep(1500);
            if (customerType.ToUpper() == "P")
            {
                int rewardPoints = (customer as IRewardSystem).GetTheRewardPoints();
                Console.WriteLine($"You have total {rewardPoints} so far.\n\n");
            }
            else
            {
                Console.WriteLine("Web customer is not eligible for reward system");
            }
        }