private void AddStudentClick()
 {
     if (Students.Count != 0)
     {
         var newStudent = new Student(_index++, "LastName", "FirstName", 16, "");
         _repo.AddStudent(newStudent);
         Students.Add(new StudentsViewModel(newStudent));
     }
 }
 public bool AddStudent(NewPersonDTO request)
 {
     try
     {
         return(_StudentsRepo.AddStudent(request.ClientId, request.Name, request.LastName1, request.LastName2, request.Birthday, request.Genre));
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Example #3
0
        public void AddStudent(Student student)
        {
            if (student.FirstName == null || student.LastName == null || student.ParentName == null ||
                student.Phone == null)
            {
                return;
            }
            var repo = new StudentsRepository(_connectionString);

            repo.AddStudent(student);
            return;
        }
Example #4
0
 public ActionResult Create(StudentsModel model)
 {
     if (ModelState.IsValid)
     {
         int StudentNo = repository.AddStudent(model);
         if (StudentNo > 0)
         {
             ModelState.Clear();
             ViewBag.Issuccess = "Data Added";
         }
     }
     return(View());
 }
Example #5
0
 /// <summary>
 /// Przycisk dodający studenta
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonAddStudent_Click(object sender, EventArgs e)
 {
     GetDataFromTextBoxes();
     try
     {
         studentsRepository.AddStudent(index, fieldOfStudyId, studyVintageId, firstName, lastName, birthDate, pesel, residencePlaceId, deficit, phoneNumber, eMail);
     }
     catch (Exception)
     {
         MessageBox.Show("Nastąpił błąd, prawdopodobnie podany indeks już istnieje");
     }
     RefreshDataGridView();
 }
Example #6
0
        public void AddStudent_calls_StudentsContext_Add_and_StudentContext_SaveChanges()
        {
            var contextMock     = new Mock <StudentsContext>();
            var studentsSetMock = new Mock <DbSet <Student> >();

            contextMock.Setup(c => c.Students).Returns(studentsSetMock.Object);

            var     studentsRepository = new StudentsRepository(contextMock.Object);
            Student newStudent         = new Student();

            studentsRepository.AddStudent(newStudent);

            studentsSetMock.Verify(ss => ss.Add(newStudent), Times.Once());
        }
Example #7
0
        public ActionResult SaveStudent(StudentsViewModel data)
        {
            try
            {
                StudentsRepository.AddStudent(data.StudentToAdd, this.CurrentUser.Class_id);
                TempData["userAdded"] = "1";
            }
            catch (Exception ex)
            {
                TempData["userAdded"] = "0";
                //log to the databse
            }

            return(RedirectToAction("Show"));
        }
Example #8
0
 /// <summary>
 /// Przycisk dodający studenta
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonAddStudent_Click(object sender, EventArgs e)
 {
     GetDataFromTextBoxes();
     try
     {
         if (studentsRepository.AddStudent(index, fieldOfStudyName, studyVintageYear, firstName, lastName, birthDate, pesel, residencePlaceId, deficit, phoneNumber, eMail))
         {
             labelOperationStatus.Text = "DODANO STUDENTA O INDEKSIE " + index;
             RefreshDataGridView();
         }
         else
         {
             labelOperationStatus.Text = "BŁĄD PRZY DODAWANIU STUDENTA O INDEKSIE " + index;
         }
     }
     catch (Exception)
     {
         labelOperationStatus.Text = "BŁĄD PRZY DODAWANIU STUDENTA O INDEKSIE " + index;
         MessageBox.Show("Nastąpił błąd, prawdopodobnie podany indeks już istnieje");
     }
 }
Example #9
0
 public async Task AddStudentAsync(Student student)
 {
     studentsRepository.AddStudent(student);
     await studentsRepository.TryAndSaveChangesAsync();
 }