Exemplo n.º 1
0
        public ActionResult Show(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Customer customer = db.Customers.SqlQuery("select * from customers where CustomerId=@id", new SqlParameter("@id", id)).FirstOrDefault();

            if (customer == null)
            {
                return(HttpNotFound());
            }
            string        ShowAllReviews = "select * from Reviews where CustomerId = @id";
            SqlParameter  param          = new SqlParameter("@id", id);
            List <Review> RecentReviews  = db.Reviews.SqlQuery(ShowAllReviews, param).ToList();

            string       ShowReviewedComics = "select * from comics inner join reviews on comics.comicid = reviews.comicid where CustomerId = @id";
            SqlParameter param2             = new SqlParameter("@id", id);
            List <Comic> ReviewedComics     = db.Comics.SqlQuery(ShowReviewedComics, param2).ToList();

            ShowCustomer viewmodel = new ShowCustomer();

            viewmodel.Customer = customer;      //display the chosen customer
            viewmodel.Reviews  = RecentReviews; //display the reviews customer made
            viewmodel.Comics   = ReviewedComics;

            return(View(viewmodel));
            //To do: Display reviews customer made
        }
        public ActionResult Show(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Customer       customer         = db.Customers.SqlQuery("select * from customers where customerid=@CustomerID", new SqlParameter("@CustomerID", id)).FirstOrDefault();
            string         second_query     = "Select * from invoices join customers on customers.customerid=invoices.customerid where customers.customerid=@CustomerID";
            SqlParameter   sqlparam         = new SqlParameter("@CustomerID", id);
            List <Invoice> CustomerInvoices = db.Invoices.SqlQuery(second_query, sqlparam).ToList();
            ShowCustomer   viewmodel        = new ShowCustomer();

            viewmodel.customer = customer;
            viewmodel.invoices = CustomerInvoices;
            return(View(viewmodel));
        }
        /// <summary>
        /// To gather information of particular customer with selected customerID
        /// </summary>
        /// <param name="id">CustomerID</param>
        /// <returns>Return particular customer information. Using View Modal, set a limit on what can be view by the client side and also able to set [DisplayName] to change the column name that will appaered in the View.  </returns>
        // GET: Customer/Details/5
        public ActionResult Details(int id)
        {
            ShowCustomer        ViewModel            = new ShowCustomer();
            string              findcustomerurl      = "customerdata/findcustomer/" + id;
            HttpResponseMessage findcustomerresponse = client.GetAsync(findcustomerurl).Result;

            if (findcustomerresponse.IsSuccessStatusCode)
            {
                //Sending findcustomerresponse request to data controller,
                //if request send succeed (status code 200), Please retienve me this customer information (based on CustomerDto.)
                //If failed, direct to Error action (View)

                CustomerDto SelectedCustomer = findcustomerresponse.Content.ReadAsAsync <CustomerDto>().Result;
                ViewModel.customer = SelectedCustomer;

                return(View(ViewModel));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            if (SQL.CheckConnection())
            {
                SQL.CreateDatabase();
            }

            int      homeChoice, typeChoice, usrActionChoice, admActionChoice, newOldChoice;
            Customer customer;

            do
            {
                homeChoice = PickStart.View();
                if (homeChoice == 0)
                {
                    typeChoice = PickUserType.View();
                    if (typeChoice == 0)
                    {
                        newOldChoice = PickNewOrOldCustomer.View();
                        if (newOldChoice == 0)
                        {
                            customer = CustomerLogin.View();
                        }
                        else
                        {
                            customer = CreateCustomer.View();
                        }
                        ShowCustomer.View(customer);
                        do
                        {
                            usrActionChoice = PickCustomerActions.View();
                            switch (usrActionChoice)
                            {
                            case 0:
                                CreateBooking.View(customer);
                                break;

                            case 1:
                                ShowCustomerBookings.View(customer);
                                break;

                            case 2:
                                customer = UpdateCustomer.View(customer);
                                break;

                            case 3:
                                Delete.Customer(customer.CustomerId);
                                usrActionChoice = 4;
                                break;

                            default:
                                break;
                            }
                        } while (usrActionChoice != 4);
                    }
                    else if (typeChoice == 1)
                    {
                        do
                        {
                            admActionChoice = PickAdminActions.View();
                            switch (admActionChoice)
                            {
                            case 0:
                                CreateMovie.View();
                                break;

                            case 1:
                                ShowCustomers.View();
                                break;

                            default:
                                break;
                            }
                        } while (admActionChoice != 2);
                    }
                }
            } while (homeChoice == 0);
        }