Inheritance: MonoBehaviour
Beispiel #1
0
        public ActionResult CheckOutEquipment(CheckOutEquipmentModel formdata)
        {
            CheckOutEquipmentModel vm     = new CheckOutEquipmentModel();
            EquipmentViewer        viewer = new EquipmentViewer();

            vm.Equipment = viewer.Getequipment(formdata.Buildingname);
            return(View(vm));
        }
Beispiel #2
0
        public ActionResult CheckOutEquipment(CheckOutEquipmentModel formdata)
        {
            long   studentid = formdata.StudentID;
            string building  = formdata.Building.Buildingname;

            EquipmentViewer            equipment_viewer = new EquipmentViewer();
            IList <EquipmentViewModel> equipment        = equipment_viewer.Getequipment(building);

            NewCheckoutDTO dto = new NewCheckoutDTO();

            dto.EquipmentID = formdata.EquipmentID;
            dto.Status      = "Out";
            dto.StudentID   = studentid;

            NewCheckoutCreator package_Creator = new NewCheckoutCreator(); //??

            package_Creator.CreatePackage(dto);

            return(RedirectToAction("AfterCheckOut", "CheckOut"));
        }
Beispiel #3
0
        public ActionResult CheckInEquipment(CheckInEquipmentModel formdata)
        {
            //?? display buildings

            long   studentid = formdata.StudentID;
            string building  = formdata.Building.Buildingname;

            EquipmentViewer            equipment_viewer = new EquipmentViewer();
            IList <EquipmentViewModel> equipment        = equipment_viewer.GetequipmentByStudent(studentid);

            var model = new CheckInEquipmentModel();

            model.StudentID = studentid;
            model.Equipment = equipment;

            NewCheckoutDTO dto = new NewCheckoutDTO();

            dto.EquipmentID = formdata.Equipment;
            dto.Status      = "In";
            dto.StudentID   = 0;
            //?? return View(model);
            return(RedirectToAction("AfterCheckIn", "CheckOut"));
        }
        //create student

        private static void CreateStudent()
        {
            int    room_number;
            long   student_id;
            string first_name, last_name, building_name;

            if (_buildingViewer == null)
            {
                _buildingViewer = new EquipmentViewer();
            }
            if (_roomViewer == null)
            {
                _roomViewer = new RoomViewer();
            }

            IList <BuildingViewModel> building = _buildingViewer.GetAllBuildingname();
            IList <RoomViewModel>     rooms;
            IList <StudentViewModel>  students;

            //TODO ILists

            WriteHeader();
            WriteCreateStudentHeader();

            //get student ID
            Console.WriteLine("Enter Student ID: ");
            string str_student_id = (Console.ReadLine());

            //validate student ID
            if (!Int64.TryParse(str_student_id, out student_id) || student_id > 9079999999 || student_id < 9070000000)
            {
                Console.WriteLine("Invalid student ID.  Press any key...");
                Console.ReadKey();
                return;
            }

            ////TODO check if student id is already in use
            //students = _studentViewer.GetStudent(student_id);
            //if(students != null)
            //{
            //    Console.WriteLine("Student ID already exists.Press any key...");
            //    Console.ReadKey();
            //    return;
            //}

            //input first and last name
            Console.WriteLine("Enter student first name: ");
            first_name = Console.ReadLine();
            Console.WriteLine("Enter student last name: ");
            last_name = Console.ReadLine();

            ////write building names on screen
            //for (var i = 0; i < building.Count; i++)
            //{
            //    Console.WriteLine("{0}. {1} {2}", building[i]);
            //}
            CommandPrompt("Type building name: ");
            building_name = Console.ReadLine();

            ////TODO validate building name
            //if (!building.Contains(building_name)) //TODO
            //{
            //    Console.WriteLine("Invalid building entry.  Press any key...");
            //    Console.ReadKey();
            //    return;
            //}

            //building is valid - grab open rooms
            rooms = _roomViewer.GetOpenRoomsByBuilding(building_name);

            //TODO room
            for (var i = 0; i < rooms.Count; i++)
            {
                Console.WriteLine("Open rooms in " + building_name);
                Console.WriteLine("{0}. {1} {2}", rooms[i]);
            }
            CommandPrompt("Select open room: ");
            string str_room_number = Console.ReadLine();

            //TODO validate room
            //if (!Int32.TryParse(str_room_number, out room_number) || !rooms.Contains(room_number))
            //{
            //    Console.WriteLine("Invalid room number.  Press any key...");
            //    Console.ReadKey();
            //    return;
            //}

            //TODO Will not need once validation works
            room_number = Convert.ToInt32(str_room_number);

            //TODO summary screen
            WriteHeader();
            WriteCreateStudentHeader();
            Console.WriteLine("Student Details:");
            Console.WriteLine("Student Id: " + student_id);
            Console.WriteLine("Name: " + first_name + " " + last_name);
            Console.WriteLine("Building: " + building_name);
            Console.WriteLine("Room number: " + room_number);
            //TODO meal plan
            CommandPrompt("Is this correct? (Y/N)");
            string str_response = Console.ReadLine();


            //pass to DTO
            if (str_response.ToLower() == "y")
            {
                NewStudentDTO newStudent = new NewStudentDTO()
                {
                    StudentID    = student_id,
                    Firstname    = first_name,
                    Lastname     = last_name,
                    Buildingname = building_name,
                    Roomnumber   = room_number
                                   //TODO meal_plan = meal_plan
                };

                var _creator = new NewStudentCreator();

                _creator.CreateStudent(newStudent);


                Console.WriteLine("Student created successfully.");
                Console.WriteLine("Press any key...");
                Console.ReadKey();
                return;
            }
        }