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")); } }
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")); } }
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); } }
private void SetCustomer(string imei) { try { WebCustomer.Customer = WebCustomer.GetByImei(imei); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); WebCustomer.Customer = null; } }
private void FailedToServe(WebCustomer customer) { Clients.All.failedToServe(customer.Id); }
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"); } }