<repo_name>jbavitan/ShareAThon<file_sep>/public/javascripts/Giving.js
var app = angular.module('myApp', []);

app.controller('givingController',function($scope, $http){
    
    $scope.experties = ['law', 'sport', 'music' ,'programmer'];
    $scope.infoToSend;
    $scope.showMatch;
    $scope.showNotMatch;
    
    $scope.chooseExp = function(experty){
        $http.get("/getSubCatagories/" + experty).success(function(catagoryList){
            $scope.catagoryList = catagoryList;
        });
    }   
    
    $scope.chooseSub = function(subCatagory){
        $scope.chosenSub = subCatagory;
    }
    
    $scope.confirm = function(){
        $http.post("/sendInfo", $scope.infoToSend).success(function(confirmation){
           $scope.showMatch = confirmation;
           $scope.showNotMatch = !confirmation;
        }).error(function(){
            alert("Error with the server");
        })
    }
    
    $scope.DisConfirm = function(){
        alert("You have declined the confirmation... To confirm press yes");
    }
})<file_sep>/app/controllers/CityController.java
package controllers;

import io.ebean.Ebean;
import models.City;
import play.libs.Json;
import play.mvc.Controller;
import play.mvc.Result;

public class CityController extends Controller {
	
	public Result getCities() {
		return ok(Json.toJson(Ebean.find(City.class).findList()));
	}

}
<file_sep>/app/controllers/SubCategoryController.java
package controllers;

import io.ebean.Ebean;
import models.SubCategory;
import play.libs.Json;
import play.mvc.Controller;
import play.mvc.Result;

public class SubCategoryController extends Controller {
	
	public Result getSubCategory() {
		return ok(Json.toJson(Ebean.find(SubCategory.class).findList()));
	}
}
<file_sep>/app/controllers/CategoryController.java
package controllers;

import io.ebean.Ebean;
import models.Category;
import play.libs.Json;
import play.mvc.Controller;
import play.mvc.Result;

public class CategoryController extends Controller {
	
	public Result getCategories() {
		
		return ok(Json.toJson(Ebean.find(Category.class).findList()));
	}
}
<file_sep>/app/controllers/MeetingController.java
package controllers;

import java.util.Date;

import com.fasterxml.jackson.databind.JsonNode;

import io.ebean.Ebean;
import models.Meeting;
import play.libs.Json;
import play.mvc.Controller;
import play.mvc.Result;

public class MeetingController extends Controller {
	
	public Result getMeetings() {
		return ok(Json.toJson(Ebean.find(Meeting.class).findList()));
	}
	
	
	public Result UpdateMeeting() {
		
		Ebean.update(createMeeting());
		
		return ok();
	}
	
	
	public Result DeleteMeeting() {
		
		Ebean.delete(createMeeting());
		
		return ok();
	}
	
	private static Meeting createMeeting() {
		
		JsonNode request = request().body().asJson();
		
		return (new Meeting(request.findValue("id").asInt(), 
						    request.findValue("requestUser").asInt(), 
						    request.findValue("offerUser").asInt(), 
						    new Date(request.findValue("Date").asLong()), 
						    request.findValue("location").asInt()));
	}

}
