Exemplo n.º 1
0
        public HomeModule()
        {
            Get["/"] = _ =>
            {
                return(View["parcel_form.html"]);
            };
            Get["/parcel_cost"] = _ =>
            {
                ParcelVariables myParcelVariables = new ParcelVariables
                {
                    width    = Request.Query["width"],
                    length   = Request.Query["length"],
                    height   = Request.Query["height"],
                    weight   = Request.Query["weight"],
                    distance = Request.Query["distance"],
                };

                int newVolume = myParcelVariables.width * myParcelVariables.height * myParcelVariables.length;
                int newPrice  = newVolume * myParcelVariables.weight * myParcelVariables.distance;

                ParcelReturn myParcelReturn = new ParcelReturn
                {
                    volume = newVolume,
                    price  = newPrice,
                };
                return(View["parcel_cost.html", myParcelReturn]);
            };
        }
Exemplo n.º 2
0
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["index.cshtml"]);
            };

            Get["/price"] = _ => {
                ParcelVariables myParcelVariables = new ParcelVariables();

                int height;
                int width;
                int depth;
                int weight;
                //
                bool ifSuccess  = int.TryParse(Request.Query["height"], out height);
                bool ifSuccess1 = int.TryParse(Request.Query["width"], out width);
                bool ifSuccess2 = int.TryParse(Request.Query["depth"], out depth);
                bool ifSuccess3 = int.TryParse(Request.Query["weight"], out weight);

                if (!int.TryParse(Request.Query["height"], out height) || !int.TryParse(Request.Query["width"], out width) || !int.TryParse(Request.Query["depth"], out depth) || !int.TryParse(Request.Query["weight"], out weight))
                {
                    return(View["error.cshtml"]);
                }
                else
                {
                    int dimension    = myParcelVariables.Volume(height, width, depth);
                    int shippingCost = myParcelVariables.CalculateCost(weight, dimension);

                    myParcelVariables.SetCost(shippingCost);

                    return(View["price.cshtml", myParcelVariables]);
                }
            };
        }
Exemplo n.º 3
0
        public HomeModule()
        {
            Get["/form"] = _ => {
                return(View["form.html"]);
            };
            Get["/parcel"] = _ => {
                int Length = 0;
                int.TryParse(Request.Query["Length"], out Length);
                int Width = 0;
                int.TryParse(Request.Query["Width"], out Width);
                int Height = 0;
                int.TryParse(Request.Query["Height"], out Height);
                int Weight = 0;
                int.TryParse(Request.Query["Weight"], out Weight);

                ParcelVariables parcel = new ParcelVariables(Length, Width, Height, Weight);
                if (Length > 0 && Width > 0 && Height > 0 && Weight > 0)
                {
                    return(View["parcel.html", parcel]);
                }
                else
                {
                    return(View["form.html", parcel]);
                }
            };
        }
Exemplo n.º 4
0
        public ActionResult Results()
        {
            ParcelVariables myParcelVariable = new ParcelVariables(Int32.Parse(Request.Query["Length"]), Int32.Parse(Request.Query["Width"]), Int32.Parse(Request.Query["Height"]), Int32.Parse(Request.Query["Weight"]));

            Console.WriteLine(Int32.Parse(Request.Query["Length"]));
            return(View("results", myParcelVariable));
        }
Exemplo n.º 5
0
        public ActionResult Receipt()
        {
            ParcelVariables myParcel = new ParcelVariables();

            myParcel.SetDimensions(Request.Query["width"], Request.Query["height"]);

            return(View("Receipt", myParcel));
        }
        public HomeModule()
        {
            Get["/"] = _ => {
                ParcelVariables myParcelVariables = new ParcelVariables(int.Parse(Request.Query["width"]), int.Parse(Request.Query["height"]), int.Parse(Request.Query["height"]), int.Parse(Request.Query["weight"]));

                return(View["index.cshtml", myParcelVariables]);
            };
            Get["/form"] = _ => {
                return(View["form.cshtml"]);
            };
        }
Exemplo n.º 7
0
 public HomeModule()
 {
     Get["/form"] = _ => {
         return(View["form.cshtml"]);
     };
     Get["/story"] = _ => {
         ParcelVariables myParcelVariables = new ParcelVariables();
         myParcelVariables.SetHeight(Request.Query["height"]);
         myParcelVariables.SetLength(Request.Query["length"]);
         myParcelVariables.SetWidth(Request.Query["width"]);
         myParcelVariables.SetWeight(Request.Query["weight"]);
         return(View["output.cshtml", myParcelVariables]);
     };
 }
Exemplo n.º 8
0
 public HomeModule()
 {
     Get["/calculate"] = _ => {
         ParcelVariables myParcelVariables = new ParcelVariables();
         myParcelVariables.SetWidth(Request.Query["width"]);
         myParcelVariables.SetLength(Request.Query["length"]);
         myParcelVariables.SetHeight(Request.Query["height"]);
         myParcelVariables.SetWeight(Request.Query["weight"]);
         return(View["index.cshtml", myParcelVariables]);
     };
     Get["/favorite_photos"] = _ => View["favorite_photos.cshtml"];
     Get["/form"]            = _ => {
         return(View["form.cshtml"]);
     };
 }
Exemplo n.º 9
0
 public HomeModule()
 {
     Get["/form"] = _ => {
         return(View["form.cshtml"]);
     };
     Get["/parcel_display"] = _ => {
         ParcelVariables myParcelVariables = new ParcelVariables
         {
             Length = Request.Query["length"],
             Width  = Request.Query["width"],
             Height = Request.Query["height"],
             Weight = Request.Query["weight"],
         };
         return(View["parcel.cshtml", myParcelVariables]);
     };
 }
Exemplo n.º 10
0
 public HomeModules()
 {
     Get["/"] = _ => {
         return(View["form.html"]);
     };
     Get["/results"] = _ => {
         ParcelVariables myParcelVariables = new ParcelVariables
         {
             Width  = Request.Query["width"],
             Length = Request.Query["length"],
             Height = Request.Query["height"],
             Weight = Request.Query["weight"]
         };
         return(View["results.cshtml", myParcelVariables]);
     };
 }
Exemplo n.º 11
0
 public HomeModule()
 {
     Get["/form"] = _ => {
         return(View["form.html"]);
     };
     Get["/parcels"] = _ => {
         ParcelVariables myParcelVariables = new ParcelVariables
         {
             Height = Request.Query["height"],
             Width  = Request.Query["width"],
             Depth  = Request.Query["depth"],
             Weight = Request.Query["weight"]
         };
         myParcelVariables.SetVolume();
         myParcelVariables.SetPrice();
         return(View["parcels.html", myParcelVariables]);
     };
 }
Exemplo n.º 12
0
        public HomeModule()
        {
            Get["/form"] = _ =>
            {
                return(View["form.cshtml"]);
            };

            Get["/parcel"] = _ =>
            {
                ParcelVariables newParcel = new ParcelVariables();
                newParcel.SetLength(Request.Query["length"]);
                newParcel.SetWidth(Request.Query["width"]);
                newParcel.SetHeight(Request.Query["height"]);
                newParcel.SetWeight(Request.Query["weight"]);
                newParcel.SetVolume();
                return(View["parcel.cshtml", newParcel]);
            };
        }
Exemplo n.º 13
0
 public HomeModule()
 {
     Get["/form"] = _ => {
         return(View["form.html"]);
     };
     Get["/shipping"] = _ => {
         Parcel          myParcel        = new Parcel(Request.Query["Width"], Request.Query["Height"], Request.Query["Length"], Request.Query["Weight"]);
         ParcelVariables parcelVariables = new ParcelVariables
         {
             Width      = myParcel.GetWidth(),
             Height     = myParcel.GetHeight(),
             Length     = myParcel.GetLength(),
             Weight     = myParcel.GetWeight(),
             Volume     = myParcel.Volume(),
             CostToShip = myParcel.CostToShip()
         };
         return(View["shipping.html", parcelVariables]);
     };
 }
Exemplo n.º 14
0
        public HomeModule()
        {
            Get["/form"] = _ => {
                return(View["form.cshtml"]);
            };
            Get["/result"] = _ => {
                // int weight = (int)(Request.Query["weight"]);
                // int height = (int)(Request.Query["height"]);
                // int width = (int)(Request.Query["width"]);
                // int depth = (int)(Request.Query["depth"]);

                // if (weight>0 && height>0 && width>0 && depth>0) {
                ParcelVariables myParcelVariables = new ParcelVariables(Request.Query["weight"], Request.Query["height"], Request.Query["width"], Request.Query["depth"]);
                return(View["result.cshtml", myParcelVariables]);
                // } else {
                //   return View["form_failure.cshtml","Invalid Input"];
                // }
            };
        }