Example #1
0
        public async Task <string> execute()
        {
            Response response = await this.model.addClassRoomToTeacher(this.classRoomName, this.teacherId);

            if (!response.isOk)
            {
                return(response.message);
            }

            ClassRoomFetchObject CFO = new ClassRoomFetchObject(this.teacherId, this.classRoomName);

            ServerResponse serverResponse = await this.model.fetchDataBaseObject(CFO, ECmdObjType.classRoomFetchObj);

            if (!serverResponse.errorResponse.isOk)
            {
                return(serverResponse.errorResponse.message);
            }

            if (CFO.isSame(serverResponse.fetchObject))
            {
                return("Success! \n" + CFO.render());
            }
            else
            {
                return("Failure :(");
            }
        }
Example #2
0
        public static void Main(string[] args)
        {
            HttpHomeWorkModel model = new HttpHomeWorkModel();

            ClassRoomFetchObject CFO = new ClassRoomFetchObject(1, "hist8");



            Task <ServerResponse> responseTask = model.fetchDataBaseObject(CFO, ECmdObjType.classRoomFetchObj);

            //responseTask.RunSynchronously();


            if (responseTask.Result.fetchObject == null)
            {
                Console.WriteLine(responseTask.Result.errorResponse.message);
            }
            else
            {
                Console.Write(responseTask.Result.fetchObject.render());
            }
            //CommandCentre commandCentre = new CommandCentre();

            //commandCentre.addCommands(
            //    new InitStudent(model, 1),
            //    new InitTeacher(model, 2),
            //    new InitClassRoom(model, "Hist8"),
            //    new InitAssignment(model, 1)
            //);

            //Console.Write(commandCentre.renderCommands());

            //Collection<int> commandKeys = new Collection<int>();

            //bool go = true;

            //while (go){

            //    string  userInput = Console.ReadLine();
            //    int commandKey = -1;


            //    try{
            //        commandKey = Convert.ToInt32(userInput);
            //    }catch{

            //        Console.WriteLine("Invalid Command Key");
            //    }

            //    if(commandKey >= 0 && commandKey <= commandCentre.commands.Count){

            //        commandKeys.Add(commandKey);
            //    }else {
            //        Console.WriteLine("Invalid Command Key");

            //    }

            //    Console.WriteLine("Execute: G, OR enter Another: Press any Key");

            //    string userInput2 = Console.ReadLine();

            //    if(userInput2 == "g" || userInput2 == "G"){

            //        go = false;
            //    }

            //}


            //Console.Write(commandCentre.executeCommands(commandKeys));
        }