Example #1
0
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here
                var student = new Student
                {
                    Name = collection.Get("Name"),
                    Surname1 = collection.Get("Surname1"),
                    Surname2 = collection.Get("Surname2"),
                    IdNumber = collection.Get("IdNumber"),
                    Email = collection.Get("Email"),
                    Phone = collection.Get("Phone"),
                    FatherName = collection.Get("FatherName"),
                    MotherName = collection.Get("MotherName")
                };

                repository.SaveStudent(student);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Example #2
0
        public void SaveStudent(Student student)
        {
            if (student.PersonId == 0)
            {
                context.Students.Add(student);
            }

            context.SaveChanges();
        }