Esempio n. 1
0
 public ActionResult Create(Models.Customer newCustomer)
 {
     try
     {
         if (ModelState.IsValid)
         {
             Library.Customer newCustomerMapped = ManualMapper.ManMap2(newCustomer);
             //var newCustomerMapped2 = ManualMapper.ManMap(newCustomerMapped);
             Repo.InsertCustomer(newCustomerMapped);
         }
         else
         {
             return(View());
         }
         return(RedirectToAction(nameof(Index)));
     }
     catch (ArgumentException ex)
     {
         ModelState.AddModelError("Id", ex.Message);
         return(View());
     }
     catch
     {
         return(View());
     }
 }
        public ActionResult Index()
        {
            IEnumerable <Library.Address> addresses = Repo.GetAddresses();
            var addressesModels = ManualMapper.ManMap2(addresses);

            return(View(addressesModels));
        }
Esempio n. 3
0
        // here, id is "OrderId"
        public ActionResult Resubmit(int id)
        {
            OrderHeader orderHeader = Repo.GetOrderByOrderId(id);

            orderHeader.OrderID   = 0;
            orderHeader.OrderDate = DateTime.Now;
            Repo.InsertOrderHeader(orderHeader);

            IEnumerable <OrderHeader>        orderHeaderList1  = Repo.GetOrderHistory(1);
            IEnumerable <Models.OrderHeader> orderHeaderList11 = ManualMapper.ManMap2(orderHeaderList1);

            return(View("OrderHistory", orderHeaderList11));
        }
Esempio n. 4
0
        public ActionResult CreateNew(int id)
        {
            Product productToOrder = Repo.GetProductByID(id);

            Library.OrderHeader orderHeader = new Library.OrderHeader();
            orderHeader.OrderDate  = DateTime.Now;
            orderHeader.CustomerID = 1;
            orderHeader.AddressID  = 1;
            orderHeader.StoreID    = 1;
            orderHeader.TotalCost  = productToOrder.UnitPrice;
            Repo.InsertOrderHeader(orderHeader);

            IEnumerable <OrderHeader>        orderHeaderList1  = Repo.GetOrderHistory(1);
            IEnumerable <Models.OrderHeader> orderHeaderList11 = ManualMapper.ManMap2(orderHeaderList1);

            return(View("OrderHistory", orderHeaderList11));
        }
Esempio n. 5
0
        public ActionResult Index([FromForm] string firstName, [FromForm] string lastName, [FromForm] string password, [FromForm] string confirmpassword)
        {
            if (confirmpassword == null)
            {
                bool exists = Repo.VerifyCustomer(firstName, lastName, password);
                {
                    if (exists == true)
                    {
                        Library.Customer customer = Repo.SearchCustomerByNameandPassword(firstName, lastName, password);
                        IEnumerable <Library.OrderHeader> orderHeaderList       = Repo.GetOrderHistoryCustomer(customer.CustomerID);
                        IEnumerable <Models.OrderHeader>  orderHeaderModelsList = ManualMapper.ManMap2(orderHeaderList);
                        return(View(orderHeaderModelsList));
                    }
                    else
                    {
                        return(RedirectToAction());
                    }
                }
            }
            else
            {
                if (confirmpassword == password)
                {
                    Customer customerToInsert = new Library.Customer();
                    customerToInsert.FirstName        = firstName;
                    customerToInsert.LastName         = lastName;
                    customerToInsert.CustomerPassword = password;
                    Repo.InsertCustomer(customerToInsert);

                    Library.Customer customer = Repo.SearchCustomerByNameandPassword(firstName, lastName, password);
                    IEnumerable <Library.OrderHeader> orderHeaderList       = Repo.GetOrderHistoryCustomer(customer.CustomerID);
                    IEnumerable <Models.OrderHeader>  orderHeaderModelsList = ManualMapper.ManMap2(orderHeaderList);
                    return(View(orderHeaderModelsList));
                }
                else
                {
                    return(RedirectToAction());
                }
            }
        }
Esempio n. 6
0
        public ActionResult OrderHistory(int sort)
        {
            switch (sort)
            {
            case 1:
            {
                IEnumerable <OrderHeader> orderHeaderList1 = Repo.GetOrderHistory(1);
                var orderHeaderList11 = ManualMapper.ManMap2(orderHeaderList1);
                return(View(orderHeaderList11));
            }

            case 2:
            {
                IEnumerable <OrderHeader> orderHeaderList2 = Repo.GetOrderHistory(2);
                var orderHeaderList21 = ManualMapper.ManMap2(orderHeaderList2);
                return(View(orderHeaderList21));
            }

            case 3:
            {
                IEnumerable <OrderHeader> orderHeaderList3 = Repo.GetOrderHistory(3);
                var orderHeaderList31 = ManualMapper.ManMap2(orderHeaderList3);
                return(View(orderHeaderList31));
            }

            case 4:
            {
                IEnumerable <OrderHeader> orderHeaderList4 = Repo.GetOrderHistory(4);
                var orderHeaderList41 = ManualMapper.ManMap2(orderHeaderList4);
                return(View(orderHeaderList41));
            }

            default:
                IEnumerable <OrderHeader> orderHeaderList = Repo.GetOrderHistory(1);
                var orderHeaderList111 = ManualMapper.ManMap2(orderHeaderList);
                return(View(orderHeaderList111));
            }
        }
Esempio n. 7
0
 public ActionResult Delete(int id)
 {
     Library.Customer customer      = Repo.GetCustomerByID(id);
     Models.Customer  customerModel = ManualMapper.ManMap2(customer);
     return(View(customerModel));
 }
Esempio n. 8
0
        public ActionResult Index()
        {
            IEnumerable <Models.Customer> customers = ManualMapper.ManMap2(Repo.GetCustomers());

            return(View(customers));
        }
        public ActionResult Index()
        {
            IEnumerable <Models.Product> products = ManualMapper.ManMap2(Repo.GetProducts());

            return(View(products));
        }