Example #1
0
 public HomeModule()
 {
     Get ["/"]      = _ => View ["pet_form.cshtml"];
     Post ["/pets"] = _ => {
         Pet newPet = new Pet
                      (
             Request.Form["petName"]
                      );
         return(View ["pet.cshtml", newPet]);
     };
     Post ["/pet/feed"] = _ => {
         List <Pet> list       = Pet.GetAll();
         Pet        currentPet = list[0];
         currentPet.FeedPet();
         return(View ["pet.cshtml", currentPet]);
     };
     Post ["/pet/play"] = _ => {
         List <Pet> list       = Pet.GetAll();
         Pet        currentPet = list[0];
         currentPet.PlayWithPet();
         return(View ["pet.cshtml", currentPet]);
     };
     Post ["/pet/sleep"] = _ => {
         List <Pet> list       = Pet.GetAll();
         Pet        currentPet = list[0];
         currentPet.GivePetSleep();
         return(View ["pet.cshtml", currentPet]);
     };
     Post ["/pet/time"] = _ => {
         List <Pet> list       = Pet.GetAll();
         Pet        currentPet = list[0];
         currentPet.MakeTimePass();
         return(View ["pet.cshtml", currentPet]);
     };
 }
Example #2
0
 public HomeModule()
 {
     Get["/"] = _ => {
         List <Pet> allPets = Pet.GetAll();
         if (allPets.Count >= 0)
         {
             return(View["index.cshtml", allPets]);
         }
         else
         {
             return(View["index.cshtml"]);
         }
     };
     Post["/"] = _ => {
         Pet        newPet  = new Pet(Request.Form["new-pet"]);
         List <Pet> allPets = Pet.GetAll();
         return(View["index.cshtml", allPets]);
     };
     Post["/time"] = _ => {
         Pet.TimePass();
         List <Pet> allPets = Pet.GetAll();
         return(View["index.cshtml", allPets]);
     };
     Get["/pets/{id}"] = parameters => {
         Pet pet = Pet.Find(parameters.id);
         return(View["/pet.cshtml", pet]);
     };
     Post["/pets/{id}/food"] = parameters => {
         Pet pet = Pet.Find(parameters.id);
         pet.FeedPet();
         return(View["pet.cshtml", pet]);
     };
     Post["/pets/{id}/attention"] = parameters => {
         Pet pet = Pet.Find(parameters.id);
         pet.AttentionPet();//increase attention
         return(View["pet.cshtml", pet]);
     };
     Post["/pets/{id}/rest"] = parameters => {
         Pet pet = Pet.Find(parameters.id);
         pet.RestPet();//increase rest
         return(View["pet.cshtml", pet]);
     };
     Post["/clear"] = _ => {
         List <Pet> allPets = Pet.GetAll();
         Pet.ClearAll();
         return(View["index.cshtml", allPets]);
     };
 }
Example #3
0
 public HomeModule()
 {
     Get["/"]     = _ => View["index.cshtml"];
     Get["/pets"] = _ =>
     {
         List <Pet> allPets = Pet.GetAll();
         return(View["pets.cshtml", allPets]);
     };
     Post["/pets"] = _ =>
     {
         Pet        newPet  = new Pet(Request.Form["petName"], Request.Form["petType"]);
         List <Pet> allPets = Pet.GetAll();
         return(View["pets.cshtml", allPets]);
     };
     Get["/pet/{id}"] = parameters =>
     {
         Pet currentPet = Pet.Find(parameters.id);
         return(View["pet.cshtml", currentPet]);
     };
     Post["/{action}/{id}"] = parameters =>
     {
         Pet.PassTime();
         Pet currentPet = Pet.Find(parameters.id);
         if (parameters.action == "feed")
         {
             currentPet.SetFood(currentPet.GetFood() + 30);
             currentPet.SetLove(currentPet.GetLove() + 25);
         }
         else if (parameters.action == "love")
         {
             currentPet.SetLove(currentPet.GetLove() + 18);
             currentPet.SetRest(currentPet.GetRest() - 4);
         }
         else if (parameters.action == "rest")
         {
             currentPet.SetRest(currentPet.GetRest() + 60);
             currentPet.SetLove(currentPet.GetLove() + 30);
         }
         return(View["pet.cshtml", currentPet]);
     };
 }