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]; }; }
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]; } }; }
public HomeModule() { Get["/"]= _ => { return View["form.html"]; }; Get["/parcel"] = _ =>{ ParcelVariables myParcelVariables = new ParcelVariables { Length = Request.Query["length"], Width = Request.Query["width"], Weight = Request.Query["weight"], Price = 0 }; myParcelVariables.Price = ((myParcelVariables.Length * myParcelVariables.Width) + myParcelVariables.Weight); return View["form.html", myParcelVariables]; }; }