Example #1
0
 public ActionResult Login(CustomerCRVM customerVM)
 {
     if (ModelState.IsValid)
     {
         Customer customer = _storeBL.GetCustomerByEmail(customerVM.CustomerEmail);
         if (customer == null)
         {
             return(NotFound());
         }
         HttpContext.Session.SetString("CustomerEmail", customer.CustomerEmail);
         HttpContext.Session.SetInt32("CustomerID", customer.Id);
         return(Redirect("/"));
     }
     return(BadRequest("Invalid model state"));
 }
 public ActionResult Create(CustomerCRVM newCustomer)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _strBL.AddCustomer(_mapper.cast2Customer(newCustomer));
             return(Redirect("../Home/Index"));
         }
         catch
         {
             return(View());
         }
     }
     return(View());
 }
 public ActionResult Create(CustomerCRVM newCustomer)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _storeBL.AddCustomer(_mapper.cast2Customer(newCustomer));
             return(RedirectToAction(nameof(Index)));
         }
         catch
         {
             return(View());
         }
     }
     return(View());
 }
Example #4
0
 public ActionResult Create(CustomerCRVM newCustomer)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _logger.LogWarning($"Customer {newCustomer.CustomerName} has been created!");
             _storeBL.CreateCustomer(_mapper.cast2Customer(newCustomer));
             return(RedirectToAction(nameof(Index)));
         }
         catch
         {
             return(View());
         }
     }
     return(View());
 }
Example #5
0
 public ActionResult Create(CustomerCRVM newCustomer)
 {
     if (ModelState.IsValid)
     {
         try
         {
             Customer newCustomerModel = new Customer();
             newCustomerModel = _GRBiz.AddCustomer(_mapper.cast2Customer(newCustomer));
             _GRBiz.newCart(newCustomerModel.ID);
             _logger.LogInformation($"New customer: Customer: {newCustomer.FirstName} {newCustomer.LastName} w/ Email: {newCustomer.Email}");
             return(RedirectToAction(nameof(Homepage)));
         }
         catch
         {
             return(View());
         }
     }
     return(View());
 }
Example #6
0
        public ActionResult Create(CustomerCRVM newCustomer)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    _customerBL.AddCustomer(_mapper.cast2Customer(newCustomer));
                    Log.Information($"Customer created-- Email: {newCustomer.CustomerEmail}");

                    //move this loop to BL
                    foreach (var loc in _locationBL.GetLocations())
                    {
                        CustomerCart cart = new CustomerCart();
                        cart.CustId         = _customerBL.GetCustomerByEmail(newCustomer.CustomerEmail).Id;
                        cart.LocId          = loc.Id;
                        cart.CurrentItemsId = _orderLineItemBL.Ident_Curr() + 1;
                        _cartBL.AddCustomerCart(cart);
                        CustomerOrderLineItem orderLineItem = new CustomerOrderLineItem();
                        orderLineItem.OrderId   = cart.CurrentItemsId;
                        orderLineItem.ProdId    = null;
                        orderLineItem.Quantity  = 0;
                        orderLineItem.ProdPrice = 0;
                        _orderLineItemBL.AddCustomerOrderLineItem(orderLineItem);
                    }
                    //Helper.WriteInformation($"Customer created-- Email: {newCustomer.CustomerEmail}");

                    return(Redirect("/Customer/Login"));
                }
                catch (Exception e)
                {
                    Helper.WriteError(e, "Error");
                    Helper.WriteFatal(e, "Fatal");
                    Helper.WriteVerbose(e, "Verbose");
                    return(View());
                }
                finally
                {
                }
            }
            return(View());
        }