Esempio n. 1
0
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["Rectangle_forms.cshtml"]);
            };
            Get["/rectangle_all"] = _ => {
                List <Rectangle> allRectangles = Rectangle.GetSides();
                return(View["Rectangle_all.cshtml", allRectangles]);
            };
            Post["/rectangle-result"] = _ => {
                Dictionary <string, object> Shapes = new Dictionary <string, object>();
                Rectangle inputRectangle           = new Rectangle(Request.Form["length"], Request.Form["width"]);
                Shapes.Add("ResultingRectangle", inputRectangle);

                if (inputRectangle.IsSquare())
                {
                    Cube inputCube = new Cube(inputRectangle);
                    Shapes.Add("ResultingCube", inputCube);
                }
                inputRectangle.SaveRectangle();
                return(View["Rectangle_results.cshtml", Shapes]);
            };
            Post["/rectangle_cleared"] = _ => {
                Rectangle.ClearAll();
                return(View["Rectangle_cleared.cshtml"]);
            };
        }
Esempio n. 2
0
        // homeModule is a method that handles routing of the files
        public HomeModule()
        {
            // this tells the (home page aka root, or "/")  to return the file from the View folder called "rectable_form.cshtml"
            Get["/"] = _ => {
                return(View["rectangle_form.cshtml"]);
            };

            Get["/rectangle_result"] = _ => {
                // dictionary is built into c#, Shapes is the actual variable name.
                Dictionary <string, object> Shapes = new Dictionary <string, object>();
                Rectangle myRectangle = new Rectangle(Request.Query["side-length"], Request.Query["side-width"]);
                Shapes.Add("ResultingRectangle", myRectangle);

                // this takes the two sides in recangle and runs a method to check if they are equal
                if (myRectangle.IsSquare())
                {
                    // if they are equaly, create a new instance of Cube object called myCube and pass in the information from myRectangle
                    Cube myCube = new Cube(myRectangle);
                    // the dictionary "Shpaes" has the method add() called on it, passing in a string 'ResultingCube', and the object myCube
                    // which contains the information from myRectangle;
                    Shapes.Add("ResultingCube", myCube);
                }
                // this returens rectangle_result from the view folder, along with the dictionary called shapes.
                return(View["rectangle_result.cshtml", Shapes]);
            };
        }
Esempio n. 3
0
    public HomeModule()
    {
      Get["/"] = _ => {
        return View["rectangle_form.cshtml"];
      };
      Get["/rectangle_result"] = _ => {
        Dictionary<string, object> Shapes = new Dictionary<string, object>();
        Rectangle myRectangle = new Rectangle(Request.Query["side-length"], Request.Query["side-width"]);
        Shapes.Add("ResultingRectangle", myRectangle);

        if (myRectangle.IsSquare()) {
          Cube myCube = new Cube(myRectangle);
          Shapes.Add("ResultingCube", myCube);
        }
        return View["rectangle_result.cshtml", Shapes];
      };
    }
        public HomeModule()
        {
            Get["/"] = _ => {
            return View["index.cshtml"];
              };
              Get["/rectangle"] = _ => {
            Dictionary<string, object> shapes = new Dictionary<string, object>();
            Rectangle myRectangle = new Rectangle(Request.Query["side-length"], Request.Query["side-width"]);
            shapes.Add("shape1", myRectangle);

            if (myRectangle.IsSquare()) {
              Cube myCube = new Cube(myRectangle);
              shapes.Add("shape2", myCube);
            }
            return View["rectangle.cshtml", shapes];
              };
        }
Esempio n. 5
0
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["rectangle_form.cshtml"]);
            };
            Get["/rectangle_result"] = _ => {
                Dictionary <string, object> Shapes = new Dictionary <string, object>();
                Rectangle myRectangle = new Rectangle(Request.Query["side-length"], Request.Query["side-width"]);
                Shapes.Add("ResultingRectangle", myRectangle);

                if (myRectangle.IsSquare())
                {
                    Cube myCube = new Cube(myRectangle);
                    Shapes.Add("ResultingCube", myCube);
                }
                return(View["rectangle_result.cshtml", Shapes]);
            };
        }
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["index.cshtml"]);
            };
            Get["/rectangle"] = _ => {
                Dictionary <string, object> shapes = new Dictionary <string, object>();
                Rectangle myRectangle = new Rectangle(Request.Query["side-length"], Request.Query["side-width"]);
                shapes.Add("shape1", myRectangle);

                if (myRectangle.IsSquare())
                {
                    Cube myCube = new Cube(myRectangle);
                    shapes.Add("shape2", myCube);
                }
                return(View["rectangle.cshtml", shapes]);
            };
        }