Exemplo n.º 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]);
     };
 }
Exemplo n.º 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]);
     };
 }