/// <summary> /// Creates a new student /// </summary> public void CreateStudent(NewStudentDTO newstudentDTO) { // create the studentDTO for persistence and populate its properties StudentDTO studentDTO = new StudentDTO() { StudentID = newStudentDTO.student_id, FirstName = newStudentDTO.first_name, Lastname = newStudentDTO.last_name, Buildingname = newStudentDTO.building_name, Roomnumber = newStudentDTO.room_number, };
/// <summary> /// Creates a new student /// </summary> public void CreateStudent(NewStudentDTO newstudentDTO) { using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["UWHousing"].ConnectionString)) //placeholder { connection.Open(); string sql //query connection.Execute(sql, new { newstudentDTO }); } }
/// <summary> /// Creates a new student /// </summary> public void CreateStudent(NewStudentDTO newStudentDTO) { // create the studentDTO for persistence and populate its properties StudentDTO studentDTO = new StudentDTO() { StudentID = newStudentDTO.StudentID, Firstname = newStudentDTO.Firstname, Lastname = newStudentDTO.Lastname, Buildingname = newStudentDTO.Buildingname, Roomnumber = newStudentDTO.Roomnumber, }; _studentDAO.CreateStudent(studentDTO); }
public ActionResult CreateStudent(CreateStudentModel formdata) { NewStudentDTO dto = new NewStudentDTO(); dto.StudentID = formdata.StudentID; dto.Firstname = formdata.FirstName; dto.Lastname = formdata.LastName; dto.Address = formdata.Address; dto.Buildingname = formdata.Buildingname; NewStudentCreator student_Creator = new NewStudentCreator(); student_Creator.CreateStudent(dto); return(RedirectToAction("AfterStudent", "Student")); }
//create student private static void CreateStudent() { int room_number; long student_id; string first_name, last_name, building_name; if (_buildingViewer == null) { _buildingViewer = new BuildingViewer(); } if (_roomViewer == null) { _roomViewer = new RoomViewer(); } UWHousing.Entities.ViewModels.IList <BuildingViewModel> building = _buildingViewer.GetAllBuildingname(); UWHousing.Entities.ViewModels.IList <RoomViewModel> rooms; UWHousing.Entities.ViewModels.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(); //validate building name if (!building.Contains(building_name)) { 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(); //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 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() { first_name = first_name, last_name = last_name, building_name = building_name, room_number = room_number //TODO meal_plan = meal_plan }; Console.WriteLine("Student created successfully."); Console.WriteLine("Press any key..."); return; } }
//create student private static void CreateStudent() { int room_number; long student_id; string first_name, last_name, building_name; if (_buildingViewer == null) { _buildingViewer = new BuildingViewer(); } 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; } //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}", i + 1, building[i].Buildingname); } //CommandPrompt("Type building name: "); Console.WriteLine("Type building name: "); building_name = Console.ReadLine(); //validate building name if ((building.Where(dorms => dorms.Buildingname.Trim() == building_name).ToList().Count) == 0) //TODO { Console.WriteLine("Invalid building entry. Press any key..."); Console.ReadKey(); return; } //building is valid - grab open rooms rooms = _roomViewer.GetOpenRoomsByBuilding(building_name); //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: "); Console.WriteLine("Select open room: "); string str_room_number = Console.ReadLine(); room_number = Convert.ToInt32(str_room_number); //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; } }