private void InitDoor() { u1 = new OfficeUser() { Birthday = DateTime.Today, EmployeeNumber = "12046", Gender = Gender.Male, Name = "Devin" }; t1 = new Teacher() { Birthday = Convert.ToDateTime("1984-1-1"), EmployeeNumber = "12334", Gender = Gender.Female, Major = "Math", Name = "StevenMath" }; Session.SaveOrUpdate(u1); Session.SaveOrUpdate(t1); Student s1 = new Student() { Birthday = Convert.ToDateTime("1983-12-20"), Gender = Gender.Male, Name = "Jack" }; Session.SaveOrUpdate(s1); Lab l1 = new Lab() { Address = "Teaching Tower 1", Description = "For chemistry", Size = 70, LabSubject = "Primary Chemistry" }; Classroom cr1 = new Classroom() { Address = "Teaching Building 2", Description = "Common Room", RoomNumber = "402", Size = 150 }; Session.SaveOrUpdate(l1); Session.SaveOrUpdate(cr1); Session.Flush(); Education e1=new Education(){Employee = t1,GraduateYear = 2003,University = "UESTC"}; Education e11 = new Education() { Employee = t1, GraduateYear = 2007, University = "BJU" }; Education e2 = new Education() { Employee = u1, GraduateYear = 2001, University = "USTC" }; t1.Educations.Add(e1); t1.Educations.Add(e11); u1.Educations.Add(e2); DoorKey doorKey = new DoorKey() { Name = "401 Key" }; doorKey.Employees = new List<Employee>(); doorKey.Employees.Add(u1); doorKey.Employees.Add(t1); Session.SaveOrUpdate(doorKey); Session.Flush(); }
public ActionResult AddTeacher(Teacher model) { IRepositories repositories = new RepositoryFactory(); repositories.TeacherRepository.Insert(Convert(model)); repositories.Commit(); return RedirectToAction("Index"); }
static void GetInformation(out Teacher st) { DateTimeFormatInfo dtfi = CultureInfo.CreateSpecificCulture("en-US").DateTimeFormat; dtfi.DateSeparator = "/"; dtfi.ShortDatePattern = @"dd/MM/yyyy"; Console.WriteLine("Enter the teacher's first name: "); st.firstName = Console.ReadLine(); Console.WriteLine("Enter the teacher's last name"); st.lastName = Console.ReadLine(); Label: Console.WriteLine("Enter the teacher's date of birth in the {0} format", dtfi.ShortDatePattern); try { st.birthDate = DateTime.Parse(Console.ReadLine(), dtfi); } catch (FormatException e) { Console.WriteLine("Invalid date, enter valid format please"); goto Label; } Console.WriteLine("Enter the teacher's address line 1 "); st.addressLine1 = Console.ReadLine(); Console.WriteLine("Enter the teacher's address line 2 "); st.addressLine2 = Console.ReadLine(); Console.WriteLine("Enter the teacher's city "); st.city = Console.ReadLine(); Console.WriteLine("Enter the teacher's state/province "); st.stateProvince = Console.ReadLine(); Console.WriteLine("Enter the teacher's zip/Postal code "); st.zipPostal = Console.ReadLine(); Console.WriteLine("Enter the teachr's country"); st.country = Console.ReadLine(); }
public WorkForm(Teacher teacher, FormLogin parentForm, StudentServiceClient proxy) { InitializeComponent(); _teacher = teacher; _parrentForm = parentForm; _proxy = proxy; }
public object[] getTeacherList(Teacher teacher, int rows, int page) { object[] result = new object[2]; ISession session = getSession(); ICriteria c = session.CreateCriteria(typeof(Teacher)); if (!string.IsNullOrEmpty(teacher.Name)) { c.Add(Restrictions.Like("Name", teacher.Name, MatchMode.Anywhere)); } if (!string.IsNullOrEmpty(teacher.Sex)) { c.Add(Restrictions.Eq("Sex", teacher.Sex)); } if (!string.IsNullOrEmpty(teacher.Sn)) { c.Add(Restrictions.Eq("Sn", teacher.Sn)); } if (!string.IsNullOrEmpty(teacher.IDcode)) { c.Add(Restrictions.Like("IDcode", teacher.IDcode, MatchMode.Anywhere)); } ICriteria c2 = (ICriteria)c.Clone(); result[0] = getCount(c2); page = page > 0 ? page : 1; c.SetFirstResult((page - 1) * rows); c.SetMaxResults(rows); result[1] = c.List<Teacher>(); return result; }
//Constructors /// <summary> /// Create new class /// </summary> /// <param name="students">Array of students</param> /// <param name="teachers">Array of teachers</param> /// <param name="id">Class id</param> public Class(Student[] students, Teacher[] teachers, string id) { this.students = new List<Student>(students); this.teachers = new List<Teacher>(teachers); this.id = id; this.comments = new List<string>(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { /* if (Session["Photo"] != null && Session["PhotoType"] != null) { img1.ImageUrl = "~/TeacherPhotoShow.aspx"; } else { img1.ImageUrl = "~/Content/default.jpg"; }*/ int id = Convert.ToInt32( Request.QueryString.Get("ID")); if (id != 0) { CQGJEntities CQGJ = new CQGJEntities(); Session["TeacherID"] = id; this.teacher = (from t in CQGJ.Teacher where t.TeacherID == id select t).First(); if (this.teacher.Photo != null || this.teacher.PhotoType != null) { img1.ImageUrl = "~/TeacherPhotoShow.aspx?ID=" + id; } else { img1.ImageUrl = "~/Content/images/user-head.jpg"; } } } }
public Course(string name, uint credits, uint weeks, Teacher teacher) { this.name = name; this.credits = credits; this.weeks = weeks; this.teacher = teacher; }
static void Main() { //some tests Student go6o = new Student("Go6o", 1245); Student to6o = new Student("To6o", 2345); to6o.AddComment("YOU SHAL NOT PAAAAASSS!!!"); to6o.AddComment("To be expelled"); Discipline borringStuff = new Discipline("Borring Stuff", 100, 1); List<Discipline> profesorovDisciplines = new List<Discipline>() { borringStuff }; Teacher profesorov = new Teacher("Profesorov", profesorovDisciplines); //create class List<Student> class1AStudents = new List<Student>() { to6o, go6o }; List<Teacher> class1ATeachers = new List<Teacher>() { profesorov }; List<SchoolClass> TUClasses2 = new List<SchoolClass>() { new SchoolClass(class1AStudents, "Class 1-A", class1ATeachers) }; School TU = new School(TUClasses2); }
public void initalizeExampleData() { if(organic_room_types == null) { organic_room_types = new HashSet<RoomType>(); organic_room_types.Add(RoomType.Projector); organic_room_types.Add(RoomType.Komin); } if(available_timeslots == null) { var available_timeslot = new TimeSlot(DayOfWeek.Monday, 9, 22); available_timeslots = new List<TimeSlot>(); available_timeslots.Add(available_timeslot); } if(rooms == null) { var room = new Room(organic_room_types, 150, available_timeslots, "ХФ210"); rooms = new HashSet<Room>(); rooms.Add(room); } if(requirements_list == null) { var requirements = new Requirements(10, available_timeslots, rooms); requirements_list = new List<Requirements>(); requirements_list.Add(requirements); var organich_chemistry_teacher = new Teacher(requirements_list[0], "Prof. Hristo Hristov"); } var organic_chemistry_teachers = new List<Teacher>(); var s = new Subject(organic_room_types, organic_chemistry_teachers, "Organic Chemistry Lectures", 1); }
public static void Main() { Class mathClass = new Class("0013"); Student studentKircho = new Student("Kircho", "0013"); Student studentNasko = new Student("Nasko", "0013"); Teacher teacherPencho = new Teacher("Pencho"); Teacher teacherIvan = new Teacher("Ivan"); mathClass.Teachers.Add(teacherPencho); mathClass.Teachers.Add(teacherIvan); mathClass.Students.Add(studentKircho); mathClass.Students.Add(studentNasko); mathClass.Comments = "This is a comment for the class"; teacherPencho.Disciplines.Add(new Disciplines("Math", 3, 5)); teacherPencho.Disciplines.Add(new Disciplines("Biology", 2, 3)); teacherPencho.Disciplines.Add(new Disciplines("Literature", 6, 3)); teacherPencho.Comments = "This is a comments for the teacher"; teacherIvan.Disciplines.Add(new Disciplines("Informatics", 5, 10)); teacherIvan.Disciplines.Add(new Disciplines("Robotics", 3, 5)); teacherIvan.Disciplines.Add(new Disciplines("Networking", 7, 5)); }
public CreationTimeTableForm(StudentServiceClient proxy, Form parentForm, Teacher techer) { InitializeComponent(); _proxy = proxy; _parentForm = parentForm; _teacher = techer; }
public static void Main() { Student student1 = new Student("Aaaa Bbb", 1); Student student2 = new Student("Cccc Ddd", 2); Student student3 = new Student("Eeee Fff", 3, "ZZZZZZZZZZZZZ"); Teacher teacher1 = new Teacher("Zzzz yyyy"); Teacher teacher2 = new Teacher("Xxxx wwww"); Discipline oop = new Discipline("oop", 12, 10, "AAAAAAAA"); Discipline csharp = new Discipline("Csharp", 20, 14); Discipline java = new Discipline("Java", 15, 16); teacher1.AddDisicipline(oop); teacher1.AddDisicipline(csharp); teacher2.AddDisicipline(oop); teacher1.ListOfDisciplines.Add(java); School mySchool = new School(); ClassInSchool myClass = new ClassInSchool("MyClassName"); myClass.AddStudent(student1); myClass.AddStudent(student2); myClass.AddStudent(student3); myClass.RemoveStudent(student1); myClass.AddTeacher(teacher1); myClass.AddTeacher(teacher2); mySchool.AddClass(myClass); System.Console.WriteLine(myClass); }
public void RemoveBuilding(Teacher teacher, int building) { if (settings.ContainsKey(teacher)) { settings[teacher].Remove(building); } }
public static void Main() { try { School softUni = new School("SoftUni"); Student student1 = new Student("Test1", "a123", "some details"); Student student2 = new Student("Test2", "a12"); Discipline discipline = new Discipline("PHP", 10, "Enter details here"); discipline.AddStudents(student1, student2); Teacher teacher = new Teacher("Angel", "Teacher details"); teacher.AddDisciplines(discipline, discipline, discipline); Class classB1 = new Class("B1", "This is class details."); classB1.AddStudents(student1, student2); classB1.AddTeachers(teacher); softUni.AddClasses(classB1); Console.WriteLine(softUni); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } }
static void Main() { Disciplines disclineOne = new Disciplines("math", 10, 12); Disciplines[] discipline = new Disciplines[] { disclineOne}; Teacher teacherOne = new Teacher("Ivan Ivanov", discipline); Teacher[] teachers = new Teacher[] { teacherOne }; Student studentOne = new Student("Stoyan", 1); Student studentTwo = new Student("Daniel", 2); Student studentThree = new Student("Yavor", 3); Student studentFour = new Student("Pesho", 5); Student studentFive = new Student("Darin", 8); Student [] students = new Student[]{studentOne,studentTwo,studentThree,studentFour,studentFive}; ClassesOfStudents classOne = new ClassesOfStudents(teachers, students, "6C"); classOne.AddTeacher(teacherOne); classOne.AddStudent(studentOne); classOne.AddStudent(studentFour); foreach (var s in students) { Console.WriteLine("Name of student:{0}",s.Name); } studentOne.AddText("vacation is over"); Console.WriteLine("The commnent of student is: {0}", studentOne.FreeTexts[0]); }
static void Main() { Discipline math = new Discipline("Math", 15, 15); Discipline biology = new Discipline("Biology", 10, 10); Discipline history = new Discipline("History", 5, 5); history.Comment = "Optional comment"; // add comment Student firstStudent = new Student("Borislav Borislavov", 2); firstStudent.Comment = "Optional comment"; // add comment Student secondStudent = new Student("Vasil Vasilev", 4); Teacher firstTeacher = new Teacher("Ivan Ivanov"); firstTeacher.AddDicipline(math); Teacher secondTeacher = new Teacher("Peter Petrov"); secondTeacher.AddDicipline(biology); secondTeacher.AddDicipline(history); secondTeacher.Comment = "Optional comment"; // add comment Class firstClass = new Class("12B"); firstClass.Comment = "Optional comment"; // add comment firstClass.AddStudent(firstStudent); firstClass.AddStudent(secondStudent); firstClass.AddTeacher(firstTeacher); firstClass.AddTeacher(secondTeacher); Console.WriteLine(firstClass); }
public AdministrationForm(StudentServiceClient proxy, Form parentForm, Teacher teacher) { InitializeComponent(); _proxy = proxy; _parentForm = parentForm; _teacher = teacher; }
public void Can_query_with_one_index_used() { //Arrange var teacher1 = new Teacher("Mathematics", "Arthur", 25, Sex.Male); var teacher2 = new Teacher("Mathematics", "Tom", 35, Sex.Male); var teacher3 = new Teacher("English", "Andrew", 35, Sex.Male); var teacher4 = new Teacher("English", "Bob", 45, Sex.Male); var teacher5 = new Teacher("Biology", "John", 55, Sex.Male); var teacher6 = new Teacher("Mathematics", "Jessica", 25, Sex.Female); var teacher7 = new Teacher("Mathematics", "Andrea", 35, Sex.Female); var teacher8 = new Teacher("English", "Kate", 35, Sex.Female); var teacher9 = new Teacher("English", "Sandra", 45, Sex.Female); var teacher10 = new Teacher("Biology", "Lara", 55, Sex.Female); var sut = CacheFactory.CreateFor<Teacher>() .WithIndex(teacher => teacher.ResponsibleForClasses) .WithIndex(teacher => teacher.Age) .WithIndex(teacher => teacher.Name) .WithIndex(teacher => teacher.Sex) .BuildUp(new[] {teacher1, teacher2, teacher3, teacher4, teacher5, teacher6, teacher7, teacher8, teacher9, teacher10}); //Act var result = sut.Query() .Where(t => t.ResponsibleForClasses, classes => classes == "Mathematics") .ToList(); //Assert result.ShouldAllBeEquivalentTo(new[] { teacher1, teacher2, teacher6, teacher7 }); }
public CheckingTeacher(Teacher Teacher, bool Checking, Visibility Visible) { this.Teacher = Teacher; this.Checking = Checking; this.Visible = Visible; this.Content = ((Domain.IDomainIdentity<Teacher>)Teacher).ID.ToString() + "-" + Teacher.Name; }
public void RemoveFavoriteClassRoom(Teacher teacher, ClassRoom classRoom) { if (favTeachersClassRooms.ContainsKey(teacher)) { favTeachersClassRooms[teacher].Remove(classRoom); } }
public void AddATeacher(Teacher teach) { Console.WriteLine("Adding a new teacher ({0}) to the class \"{1}\":", teach.Name, this.Name); this.teachers.Add(teach); Console.WriteLine("Adding completed."); Console.WriteLine(); }
public ITeacher CreateTeacher(string name) { //returns teacher object ITeacher newTeacher = new Teacher(name); return newTeacher; }
private async void btn_registrate_Click(object sender, EventArgs e) { if (tb_sName.Text == String.Empty || tb_name.Text == String.Empty || tb_pName.Text == String.Empty || tb_login.Text == String.Empty || tb_password.Text == String.Empty || tb_passwordAgain.Text == String.Empty) { MessageBox.Show("Заповніть всі поля!"); return; } if (tb_password.Text != tb_passwordAgain.Text) { MessageBox.Show("Паролі не співпадають. Введіть пароль ще раз!"); return; } Teacher teacher = new Teacher(tb_sName.Text, tb_name.Text, tb_pName.Text); try { int res = await _proxy.RegistrateTeacherAsync(teacher, tb_login.Text, tb_password.Text); if (res > 0) { MessageBox.Show("Викладача зареєстровано", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
static void Main() { SchoolClass PHPClass = new SchoolClass(); Teacher firstTeacher = new Teacher("Ivan Vankov"); PHPClass.AddTeacher(firstTeacher); Teacher secondTeacher = new Teacher("Stamat Trendafilov"); PHPClass.AddTeacher(secondTeacher); Student newStudent = new Student("Dobromir Ivanov", "756A"); PHPClass.AddStudent(newStudent); Console.WriteLine("List of all teachers: "); foreach (Human teacher in PHPClass.ClassTeachersList) { Console.WriteLine(teacher); } Console.WriteLine("\nList of all Students: "); foreach (Human student in PHPClass.ClassStudentsList) { Console.WriteLine(student); } }
static void Main() { School hogwards = new School(); Class blackMagic = new Class("Black Magic"); Teacher snape = new Teacher("Snape"); snape.Comments = "brrrrr"; Discipline blackStuffPractise = new Discipline("Black stuff and dark stuff",1,200); blackStuffPractise.Comments = "brr"; snape.AddDiscipline(blackStuffPractise); blackMagic.AddTeacher(snape); hogwards.AddClass(blackMagic); foreach (var clas in hogwards.Classes) { foreach (var teach in clas.Teachers) { foreach (var disc in teach.Disciplines) { Console.WriteLine(disc.Name); } } } }
protected void btnInsert_Click(object sender, EventArgs e) { try { usersLogin = new UsersLogin(); teachers = new Teacher(); scDao = new SchoolDao(); string strTeacherLastName = txtLastName.Text; string strTeacherFirstName = txtFirstName.Text; string strTeacherDepartment = txtDepartament.Text; string strUserEmail = inputEmail.Text; string strPassword = inputPassword.Text; teachers.TeacherLastName = strTeacherLastName; teachers.TeacherFirstName = strTeacherFirstName; teachers.TeacherDepartment = strTeacherDepartment; usersLogin.UserEmail = strUserEmail; usersLogin.UserPassword = scDao.CreatePasswordHash(strPassword); scDao.InsetTeachers(teachers, usersLogin); lblMsg.Text = "Teacher Inserted!"; btnInsert.Enabled = false; } catch (Exception ex) { lblMsg.Text=ex.Message.ToString(); } }
static void Main() { Teacher Eng = new Teacher("박미영", 35, "영어"); Thief KangDo = new Thief("야월담", 25, 3); Eng.Teach(); KangDo.Steal(); }
public void ItShouldGetStudentsWithLowestGrade() { Pupil John = new Pupil("John"); John.AddGrades(10, "Math"); John.AddGrades(5, "Math"); John.AddGrades(6, "Math"); John.AddGrades(8, "Math"); John.AddGrades(10, "Literature"); John.AddGrades(9, "Literature"); John.AddGrades(9, "Literature"); John.AddGrades(8, "Literature"); Pupil Mike = new Pupil("Mike"); Mike.AddGrades(10, "Math"); Mike.AddGrades(9, "Math"); Mike.AddGrades(8, "Math"); Mike.AddGrades(8, "Math"); Mike.AddGrades(7, "Literature"); Mike.AddGrades(9, "Literature"); Mike.AddGrades(7, "Literature"); Mike.AddGrades(8, "Literature"); Pupil Anna = new Pupil("Anna"); Anna.AddGrades(10, "Math"); Anna.AddGrades(10, "Math"); Anna.AddGrades(7, "Math"); Anna.AddGrades(8, "Math"); Anna.AddGrades(10, "Literature"); Anna.AddGrades(9, "Literature"); Anna.AddGrades(9, "Literature"); Anna.AddGrades(10, "Literature"); Pupil[] students = new Pupil[] { John, Mike, Anna }; Teacher Teacher1 = new Teacher(students); List<Pupil> expected = new List<Pupil> { John, Mike }; List<Pupil> actual = Teacher1.GetStudentsWithLowestGrade(); CollectionAssert.AreEqual(expected, actual); }
private List<Teacher> setOfTeachers; // Each class has a set of teachers. #endregion Fields #region Constructors //constructor public ClassesOfStudents(Teacher [] setOfTeachers, Student [] setOfStudents, string numberOfClasses) { this.setOfTeachers = new List<Teacher>(setOfTeachers); this.setOfStudents = new List<Student>( setOfStudents); this.numberOfClasses = numberOfClasses; this.freeText = new List<string>(); }
public Teacher GetTeacherById(int id) { Teacher aTeacher = aTeacherGateway.GetTeacherById(id); return(aTeacher); }
public async Task UpdateAsync(Teacher teacher) { _context.Teachers.Update(teacher); await _context.SaveChangesAsync(); }
public async Task AddAsync(Teacher teacher) { await _context.Teachers.AddAsync(teacher); await _context.SaveChangesAsync(); }
public ClassRoom(int id, Teacher roomTeacher) : this() { _id = id; _roomTeacher = roomTeacher; }
/// <summary> /// Verify a user login and generate the corresponded cookies /// </summary> /// <param name="roster">username</param> /// <param name="password">password</param> /// <returns></returns> public async Task <ActionResult> Login(string roster, string password) { if (ModelState.IsValid) { if (!string.IsNullOrEmpty(roster) && !string.IsNullOrEmpty(password)) { //Especial user if (roster == "0000" && password == "admin") { //Generate the cookies and save the user data var claims = new List <Claim> { new Claim(ClaimTypes.Name, roster), new Claim("FullName", "Administrator"), }; var claimsIdentity = new ClaimsIdentity( claims, CookieAuthenticationDefaults.AuthenticationScheme); var authProperties = new AuthenticationProperties { ExpiresUtc = DateTimeOffset.UtcNow.AddMinutes(5), IsPersistent = false }; return(RedirectToAction("Index", "Admin")); } else { //Verify if the user exist in the database teacher = db.Teachers.FirstOrDefault(p => p.Roaster == roster && p.Password == _encrypt(password)); if (teacher != null) { string role = "Teacher"; //Assign a role if (teacher.GetHours() == 10) { role = "Cordinator"; } //Generate the cookies to authentication and save the tecaher information var claims = new List <Claim> { new Claim(ClaimTypes.Name, teacher.Roaster), new Claim("ID", teacher.ID.ToString()), new Claim("FullName", teacher.Names + " " + teacher.MiddleName), new Claim(ClaimTypes.Role, role) }; var claimsIdentity = new ClaimsIdentity( claims, CookieAuthenticationDefaults.AuthenticationScheme); var authProperties = new AuthenticationProperties { ExpiresUtc = DateTimeOffset.UtcNow.AddMinutes(5), IsPersistent = false }; await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity), authProperties); return(RedirectToAction("Index", "Profile")); } else { return(RedirectToAction("Index", "Home", new { message = "This user doesn't exist" })); } } } else { return(RedirectToAction("Index", "Home", new { message = "Fill all the fields" })); } } return(RedirectToAction("Index", "Home")); }
public ServiceStoreWindow(Student contextStudent, Teacher ContextTeacher) { InitializeComponent(); this.DataContext = new ServiceStoreViewModel(this, contextStudent, ContextTeacher); }
public bool IsUserNameUniqueOnEdit(Teacher teacher, string username) { return(this.teacherRepository.IsUserNameUniqueOnEdit(teacher, username)); }
static void Main(string[] args) { Console.Write("Enter a Number: "); string userInput = Console.ReadLine(); Console.WriteLine("Your Number is: {0}", userInput); var dictionary = new Dictionary <string, string>(); dictionary["apple"] = "A fruit or a computer company"; Console.WriteLine(dictionary["apple"]); var someList = new List <int>(); someList.Add(1); someList.Add(2); someList.Add(3); someList.Add(5); someList.Add(8); someList.Add(11); someList.RemoveAt(0); someList.RemoveAt(2); for (int i = 0; i < someList.Count; i++) { Console.WriteLine(someList[i]); } foreach (int number in someList) { Console.WriteLine(number); } someList.ForEach(number => Console.WriteLine(number)); someList.ForEach(Console.WriteLine); string[] names = { "John", "Daryl", "Mike", "Sarah", "Michele" }; string[] moreNames = new string[5]; moreNames[0] = "John"; moreNames[1] = "Daryl"; Console.WriteLine("Size of names: {0}\nSize of moreNames: {1}", names.Length, moreNames.Length); // and so on string student = "John Smith"; char firstCharacter = student[1]; // ---- Exercise for loops ---- var animals = new List <string>(); animals.Add("Lion"); animals.Add("Tiger"); animals.Add("Bird"); animals.Add("Cat"); animals.Add("Dog"); animals.Add("Leopard"); string favoriteAnimal = "Bird"; foreach (string animal in animals) { Console.WriteLine(animal); } if (animals.Contains(favoriteAnimal)) { Console.WriteLine("I love {0} and also every other animal, including {1}", favoriteAnimal, animals[2]); // same as the above line, but without the placeholder Console.WriteLine("I love " + favoriteAnimal + "and also every other animal, including " + animals[2]); } else { Console.WriteLine("No, I don't care for those"); } // dictionary looping var person = new Dictionary <string, int>(); person.Add("Joan", 22); person.Add("Daniel", 42); person.Add("Anna", 34); // person = {Joan=22, Daniel=42, Anna=34} // loop through the hash map and return each key/value pair for (int i = 0; i < person.Count; i++) { Console.WriteLine("Key: {0}, Value: {1}", person.Keys.ElementAt(i), person[person.Keys.ElementAt(i)]); } foreach (var peep in person) { // print out the key (their name) and their value Console.WriteLine("Name: {0}, Age: {1}", peep.Key, peep.Value); } var studentData = new Dictionary <string, string>(); studentData["name"] = "Fred"; studentData["age"] = "20"; studentData["hometown"] = "Seattle"; studentData["favorite_food"] = "Pizza"; Console.WriteLine("This is {0}", studentData["name"]); Console.WriteLine("They are {0} years old", studentData["age"]); Console.WriteLine("from {0}", studentData["hometown"]); Console.WriteLine("and their favorite food is {0}", studentData["favorite_food"]); var students = new Dictionary <string, Dictionary <string, string> >(); students["Fred"] = new Dictionary <string, string>(); students["Fred"].Add("name", "Fred"); students["Fred"].Add("age", "20"); students["Fred"].Add("hometown", "Seattle"); students["Fred"].Add("favorite_food", "Pizza"); Console.WriteLine("This is {0}", students["Fred"]["name"]); var students2 = new Dictionary <string, Student>(); var someStudent = new Student("Fred", 20, "Seattle", "Pizza"); students2.Add("Fred", someStudent); var anotherStudent = new Student("Sally", 21, "Columbus", "Pasta"); students2.Add("Sally", anotherStudent); var studentWithNoData = new Student(); var sedan = new Car("blue", 4); sedan.Start(); sedan.Stop(); sedan.Drive(); Console.WriteLine("Car color: {0}", sedan.Color); Console.WriteLine("Number of Doors: {0}", sedan.NumberOfDoors); var coup = new Car("red", 2); var compact = new Car("blue"); Car.Compare(sedan, new Car()); int maxDoors = Car.MAX_DOORS; coup.Type = CarType.SPORTY; coup.NumberOfDoors = 4; if (coup == sedan) { Console.WriteLine("not sure how, but a coup and sedan are the same?"); } if (coup.Equals(sedan)) { Console.WriteLine(""); } Console.WriteLine(coup.ToString()); var vehicle = new Vehicle(); var genericAnimal = new Animal(0, "amoeba"); genericAnimal.Announce(); var bear = new Bear(1, "Yogi", 9999); bear.Announce(); var vehicles = new List <Vehicle>(); vehicles.Add(new Truck()); vehicles.Add(sedan); vehicles.Add(coup); vehicles.Add(compact); var vehicles2 = new List <IVehicle>(); var rallyCar = new RallyCar(); vehicles2.Add(new Truck()); vehicles2.Add(new Motorcycle()); vehicles2.Add(sedan); vehicles2.Add(coup); vehicles2.Add(compact); vehicles2.Add(rallyCar); var crossOver = new CrossOver(); // this won't work, because crossover doesn't implement // the IVehicle interface //vehicles2.Add(crossOver); foreach (var v in vehicles2) { v.Accelerate(10); } Drive(rallyCar); Drive(sedan); Drive(new Truck()); var pupil = new Student("John Smith", 19, "Columbus", "Pizza"); var teacher = new Teacher("Jane Doe", 31); PrintInfo(pupil); PrintInfo(teacher); // Page 21 in interfaces and extension methods example Console.WriteLine("-----------------------"); }
public void FavouritesChanged(Teacher teacher, bool isFav) { itemList.Where(x => x.Teacher == teacher).FirstOrDefault().SetFavourite(isFav); }
public static void Update(Teacher newTeacher) { using var sqlConnection = DatabaseUtility.GetSqlConnection(); new SqlCommand($"UPDATE Teacher SET Name = '{newTeacher.Name}', Age = {newTeacher.Age} WHERE Id = {newTeacher.Id}", sqlConnection) .ExecuteNonQuery(); }
public void registerTeacher(Teacher teacher) { TeacherDao logger = new TeacherDao(); logger.add(teacher); }
public HttpResponseMessage GetTeacherById(string id) { string userId = ((ClaimsPrincipal)RequestContext.Principal).FindFirst(x => x.Type == "UserId").Value; string userRole = ((ClaimsPrincipal)RequestContext.Principal).FindFirst(x => x.Type == ClaimTypes.Role).Value; logger.Info("UserRole: " + userRole + ", UserId: " + userId + ": Requesting Teacher by id: " + id); try { Teacher teacher = teachersService.GetById(id); if (teacher == null) { logger.Info("The teacher with id: " + id + " was not found."); return(Request.CreateResponse(HttpStatusCode.BadRequest, "The teacher with id: " + id + " was not found.")); } if (userRole == "admin") { logger.Info("Requesting found teacher convert for " + userRole + "role."); TeacherDTOForAdmin dto = toDTO.ConvertToTeacherDTOForAdmin(teacher, (List <IdentityUserRole>)teacher.Roles); if (dto == null) { logger.Info("Failed!"); return(Request.CreateResponse(HttpStatusCode.BadRequest, "Something went wrong.")); } logger.Info("Success!"); return(Request.CreateResponse(HttpStatusCode.OK, dto)); } else if (userRole == "teacher" && teacher.IsStillWorking == true) { logger.Info("Requesting found teacher convert for " + userRole + "role."); TeacherDTOForTeacher dto = toDTO.ConvertToTeacherDTOForTeacher(teacher); if (dto == null) { logger.Info("Failed!"); return(Request.CreateResponse(HttpStatusCode.BadRequest, "Something went wrong.")); } logger.Info("Success!"); return(Request.CreateResponse(HttpStatusCode.OK, dto)); } else if (teacher.IsStillWorking == true && (userRole == "student" || userRole == "parent")) { logger.Info("Requesting found teacher convert for " + userRole + "role."); TeacherDTOForStudentAndParent dto = toDTO.ConvertToTeacherDTOForStudentAndParent(teacher); if (dto == null) { logger.Info("Failed!"); return(Request.CreateResponse(HttpStatusCode.BadRequest, "Something went wrong.")); } logger.Info("Success!"); return(Request.CreateResponse(HttpStatusCode.OK, dto)); } else //zbog provere teacher.IsStillWorking { logger.Info("Authorisation failure. User " + userId + " is not authorised for this request."); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Access Denied. " + "We’re sorry, but you are not authorized to perform the requested operation.")); } } catch (Exception e) { logger.Error(e); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, e)); } }
public async Task <ActionResult> CreateCourse(ResponseCreateCourseViewModel oRVM) { TempData["UserMessage"] = new MessageVM() { IsSuccessful = false, Title = "Error!", Message = "Something went wrong." }; if (Helpers.Helpers.IsStaff(User)) { return(RedirectToAction("Index", "Staff")); } if (!ModelState.IsValid) { return(View(oRVM)); } CourseViewModel oCourseVM = oRVM.CourseVM; TeacherViewModel oTeacherVM = oRVM.TeacherVM; Student oStudent = db.Students.Include(s => s.Courses).Include(s => s.Teachers).SingleOrDefault(p => p.StudentId == oCourseVM.StudentId); if (oStudent == null)//Error. Student DNE. { throw new ArgumentException("CreateCourse(ResponseCreateCourseViewModel oRVM) - Student DNE."); } Parent oParent = db.Parents.Include(p => p.Children).SingleOrDefault(p => p.ParentId == SessionSingleton.Current.ParentId && p.Children.Any(s => s.StudentId == oStudent.StudentId)); if (oParent == null) //Error. This Student/Child doesn't belong to this Parent. { throw new ArgumentException("CreateCourse(ResponseCreateCourseViewModel oRVM) - Parent DNE."); } Teacher oTeacher = new Teacher() { Email = oTeacherVM.Email, FirstName = oTeacherVM.FirstName, LastName = oTeacherVM.LastName, Gender = oTeacherVM.Gender, Phone = oTeacherVM.Phone, PreferredMethodOfContact = oTeacherVM.PreferredMethodOfContact }; Course oCourse = new Course() { Name = oCourseVM.Name, TimeStart = oCourseVM.TimeStart, TimeEnd = oCourseVM.TimeEnd, ClassType = oCourseVM.ClassType, SchoolName = oCourseVM.SchoolName, Teacher = oTeacher }; oStudent.Courses.Add(oCourse); //Add Course to Student oStudent.Teachers.Add(oTeacher); //Add Teacher to Student try { if (db.SaveChanges() <= 0) { return(View(oRVM)); } } catch (Exception e) { return(View(oRVM)); } TempData["UserMessage"] = new MessageVM() { IsSuccessful = true, Title = "Success!", Message = "Your child's course has been successfully added." }; return(RedirectToAction("Index", new { StudentId = oStudent.StudentId, CourseId = oCourse.CourseId })); }
public void AddToTeachers(Teacher teacher) { base.AddObject("Teachers", teacher); }
public IActionResult AddTeacher(Teacher teacher) { _schoolData.AddTeacher(teacher); return(Created(HttpContext.Request.Scheme + "://" + HttpContext.Request.Host + HttpContext.Request.Path + "/" + teacher.TeacherId, teacher)); }
public async Task <ActionResult> AlterCourse(ResponseCreateCourseViewModel oRVM) { TempData["UserMessage"] = new MessageVM() { IsSuccessful = false, Title = "Error!", Message = "Something went wrong." }; if (Helpers.Helpers.IsStaff(User)) { return(RedirectToAction("Index", "Staff")); } if (!ModelState.IsValid) { return(View(oRVM)); } CourseViewModel oCourseVM = oRVM.CourseVM; Course oCourse = db.Courses.Include(c => c.Teacher).SingleOrDefault(c => c.CourseId == oCourseVM.CourseId); if (oCourse == null)//Error. Course DNE. { throw new ArgumentException("AlterCourse(ResponseCreateCourseViewModel oRVM) - Course DNE."); } TeacherViewModel oTeacherVM = oRVM.TeacherVM; Teacher oTeacher = oCourse.Teacher; Student oStudent = db.Students.SingleOrDefault(s => s.StudentId == oCourseVM.StudentId && s.Courses.Any(c => c.CourseId == oCourse.CourseId)); if (oStudent == null)//Error. Student DNE OR doesn't take this Course. { throw new ArgumentException("AlterCourse(ResponseCreateCourseViewModel oRVM) - Student DNE."); } Parent oParent = db.Parents.Include(p => p.Children).SingleOrDefault(p => p.ParentId == SessionSingleton.Current.ParentId && p.Children.Any(s => s.StudentId == oStudent.StudentId)); if (oParent == null) //Error. This Student/Child doesn't belong to this Parent. { throw new ArgumentException("AlterCourse(ResponseCreateCourseViewModel oRVM) - Parent DNE."); } oCourse.Name = oCourseVM.Name; oCourse.TimeStart = oCourseVM.TimeStart; oCourse.TimeEnd = oCourseVM.TimeEnd; oCourse.ClassType = oCourseVM.ClassType; oCourse.SchoolName = oCourseVM.SchoolName; oTeacher.Email = oTeacherVM.Email; oTeacher.FirstName = oTeacherVM.FirstName; oTeacher.LastName = oTeacherVM.LastName; oTeacher.Gender = oTeacherVM.Gender; oTeacher.Phone = oTeacherVM.Phone; oTeacher.PreferredMethodOfContact = oTeacherVM.PreferredMethodOfContact; try { db.SaveChanges(); } catch (Exception e) { return(View(oRVM)); } TempData["UserMessage"] = new MessageVM() { IsSuccessful = true, Title = "Success!", Message = "Your child's course has been successfully updated." }; return(RedirectToAction("Index", new { StudentId = oCourseVM.StudentId, CourseId = oCourse.CourseId })); }
public void RemoveTeacher(Teacher teacher) { this.teachers.Remove(teacher); }
public Lehrer(Teacher teacher) : base(teacher) { }
public void AddTeacher(Teacher teacher) { this.teachers.Add(teacher); }
private void button1_Click(object sender, EventArgs e) { if (comboBox3.SelectedItem != null) { if (num == 1) { Ruhm ruhm = new Ruhm(); ruhm.NimiRuhm = textBox1.Text; int arv = WorkDB.UpdateRuhm(ruhm, Convert.ToInt32(((ComboBoxItem)comboBox3.SelectedItem).HiddenValue)); if (arv != 0) { MessageBox.Show("Oli lisatud " + arv + " rida", "Valmis", MessageBoxButtons.OK, MessageBoxIcon.Information); RuhmT obj = (RuhmT)Application.OpenForms["RuhmT"]; obj.UpdateForm(); obj.dataGridView1.Update(); obj.dataGridView1.Refresh(); this.Close(); } else { MessageBox.Show("Lisamine ebaõnnestus", "Viga", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (num == 2) { Student student = new Student(); student.Nimi = textBox1.Text; student.Isikukood = textBox3.Text; student.Kool = textBox4.Text; student.Klass = int.Parse(comboBox1.SelectedItem.ToString()); student.Telefon = textBox6.Text; student.Aadress = textBox7.Text; student.RuhmID = Convert.ToInt32(((ComboBoxItem)comboBox2.SelectedItem).HiddenValue); int arv = WorkDB.UpdateStudent(student, Convert.ToInt32(((ComboBoxItem)comboBox3.SelectedItem).HiddenValue)); if (arv != 0) { MessageBox.Show("Oli lisatud " + arv + " rida", "Valmis", MessageBoxButtons.OK, MessageBoxIcon.Information); StudentT obj = (StudentT)Application.OpenForms["StudentT"]; obj.UpdateTable(); obj.dataGridView1.Update(); obj.dataGridView1.Refresh(); this.Close(); } else { MessageBox.Show("Lisamine ebaõnnestus", "Viga", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { Teacher teacher = new Teacher(); teacher.Nimi = textBox1.Text; teacher.Isikukood = textBox3.Text; teacher.Telefon = textBox6.Text; teacher.Aadress = textBox7.Text; teacher.RuhmID = Convert.ToInt32(((ComboBoxItem)comboBox2.SelectedItem).HiddenValue); int arv = WorkDB.UpdateTeacher(teacher, Convert.ToInt32(((ComboBoxItem)comboBox3.SelectedItem).HiddenValue)); if (arv != 0) { MessageBox.Show("Oli lisatud " + arv + " rida", "Valmis", MessageBoxButtons.OK, MessageBoxIcon.Information); TeacherT obj = (TeacherT)Application.OpenForms["TeacherT"]; obj.UpdateTable(); obj.dataGridView1.Update(); obj.dataGridView1.Refresh(); this.Close(); } else { MessageBox.Show("Muutmine ebaõnnestus", "Viga", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show("Check combo box", "Viga", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void UpdateTeacher(Teacher teacher) { _teacherRepository.Update(teacher); }
protected override void BuildClassName(Teacher teacher) { Console.WriteLine("Enter class name: "); teacher.className = Console.ReadLine(); }
public void AddTeacher(Teacher teacher) { _teacherRepository.Insert(teacher); }
public void RemoveTeacher(Teacher teacher) { _teacherRepository.Delete(teacher); }
static void PrintInfo(Teacher teacher) { // pass objects as references to the interface Console.WriteLine("Name: {0}, Age: {1}", teacher.Name, teacher.Age); }
protected override void BuildName(Teacher teacher) { Console.WriteLine("Enter employee name: "); teacher.name = Console.ReadLine(); }
public CreateTeacher(Teacher Instance) { this._Instance = Instance; }
public void UpdateDbTeacher(Teacher teacher) { db.Entry(teacher).State = System.Data.Entity.EntityState.Modified; // Ej using för då blir det knas på retunr typerna i get metoderna... db.SaveChanges(); // Updates all changed objects }
public TeacherWrapper(Teacher teacher) { this.teacher = teacher; }
public Teacher LoginTeacher(string userName, string password) { //Giá trị trả về của hàm này Teacher queryResult = null; //Câu lệnh truy vấn ở dạng string string queryString = "SELECT * FROM Teacher WHERE (UserName = @userName OR UserEmail = @userName) AND UserPw = @password"; //Mở kết nối đến database using (SqlConnection connection = new SqlConnection(this.ConnectionString)) { // Khởi tạo command với tham số truyền vào là userName, password SqlCommand command = new SqlCommand(queryString, connection); command.Parameters.AddWithValue("@userName", userName); command.Parameters.AddWithValue("@password", password); //Mở kết nối và thực hiện query vào database connection.Open(); SqlDataReader reader = command.ExecuteReader(); //Đọc dữ liệu trả về từ truy vấn ở trên while (reader.Read()) { Teacher teacherDto = new Teacher(); //Lấy từng cột đọc được lưu vào queryResult if (reader["UserId"] != DBNull.Value) { teacherDto.UserId = (long)reader["UserId"]; } if (reader["IdentificationCode"] != DBNull.Value) { teacherDto.IdentificationCode = (string)reader["IdentificationCode"]; } if (reader["UserName"] != DBNull.Value) { teacherDto.UserName = (string)reader["UserName"]; } if (reader["UserFullName"] != DBNull.Value) { teacherDto.UserFullName = (string)reader["UserFullName"]; } if (reader["UserDob"] != DBNull.Value) { teacherDto.UserDob = (DateTime)reader["UserDob"]; } if (reader["UserGender"] != DBNull.Value) { teacherDto.UserGender = (long)reader["UserGender"]; } if (reader["UserAddress"] != DBNull.Value) { teacherDto.UserAddress = (string)reader["UserAddress"]; } if (reader["UserMobile"] != DBNull.Value) { teacherDto.UserMobile = (string)reader["UserMobile"]; } if (reader["UserEmail"] != DBNull.Value) { teacherDto.UserEmail = (string)reader["UserEmail"]; } if (reader["UserAvatar"] != DBNull.Value) { teacherDto.UserAvatar = (string)reader["UserAvatar"]; } if (reader["UserType"] != DBNull.Value) { teacherDto.UserType = (long)reader["UserType"]; } if (teacherDto.UserId != 0) { queryResult = teacherDto; } } //Đóng kết nối reader.Close(); connection.Close(); } //Trả về kết quả return(queryResult); }