Exemplo n.º 1
0
 public ActionResult Create(FormCollection formData)
 {
     Student s = new Student(); UpdateModel(s);
     StudentRepository repository = new StudentRepository();
     repository.AddStudent(s);
     return RedirectToAction("Index");
 }
Exemplo n.º 2
0
		/// <summary>
		/// Adds a new student to the repository. Note that no validation is performed
		/// at this moment.
		/// </summary>
		/// <param name="s"></param>
		public void AddStudent( Student s )
		{
			// "Poor man's autoincrement" :-)
			s.ID = ( from student in m_students
					 select student.ID ).Max( ) + 1;

			m_students.Add( s );
		}
Exemplo n.º 3
0
		/// <summary>
		/// Updates an existing student.
		/// </summary>
		/// <param name="s"></param>
		public void UpdateStudent( Student s )
		{
			for ( int i = 0; i < m_students.Count; i++ )
			{
				if ( s.ID == m_students[i].ID )
				{
					m_students[i] = s;
					break;
				}
			}
		}