Esempio n. 1
0
 public ActionResult Edit(Student Student)
 {
     if (ModelState.IsValid)
     {
         var studentList = _StudentBLL.GetAll().TableList;
         var OldStd      = studentList.Exists(s => s.StudentName == Student.StudentName && s.StudentId != Student.StudentId);
         if (OldStd)
         {
             ModelState.AddModelError(string.Empty, "Student Name already exists.");
             return(View());
         }
         else
         {
             if (Student.StudentId == 0)
             {
                 Student = _StudentBLL.Add(Student.StudentName);
             }
             else
             {
                 _StudentBLL.Edit(Student);
             }
         }
     }
     return(RedirectToAction("Index"));
 }
        private void Btn_Add(object sender, RoutedEventArgs e)
        {
            var studentBll = new StudentBll();

            //var student = new Student()
            //{
            //    Name = TextBoxName.Text,
            //    Address = TextBoxAddres.Text,
            //    RollNumber = TextBoxRollNo.Text,
            //    Password = TextBoxPassword.Text,
            //    UserName = TextBoxUsername.Text
            //};
            //if(studentBll.Add(student))
            //    MessageBox.Show("Student Added.");

            for (int rows = 0; rows < StudentDataGrid.Items.Count - 1; rows++)
            {
                var student = new Student();
                student = (Student)StudentDataGrid.Items[rows];
                studentBll.Add(student);
            }
        }
 public int Post(Student s)
 {
     return(bll.Add(s));
 }