public async Task <IActionResult> AddStudent( CancellationToken cancellationToken, [FromBody] StudentAddBinding binding, [FromServices] IStudentRepository repository, [FromServices] StudentCreator registrar) { try{ var student = await registrar.Create( id : binding.Id, mentorId : User.GetUserId(), publicId : binding.PublicId, firstName : binding.FirstName, lastName : binding.LastName, secondName : binding.SecondName, gender : binding.Gender, cancellationToken); await repository.Save(student, cancellationToken); return(NoContent()); } catch (StudentAlreadyExistsException) { throw new ApiException(HttpStatusCode.Conflict, ErrorCodes.StudentAlreadyExists, "Student already exists"); } }
static void Main() { var app = new ApplicationService(); var training = new TrainingCreator(app); var location = new LocationCreator(app); var trainer = new TrainerCreator(app); var company = new CompanyCreator(app); var student = new StudentCreator(app); var contact = new ContactCreator(app, company); var session = new SessionCreator(app, training, trainer, location, student, company); var reader = new MsAccessReader("c:\\temp\\Database1.mdb"); var lineCount = 1; foreach (DataRow row in reader.GetRows("Formation")) { Console.Write($"Traitement de la ligne {lineCount++}\r"); training.Create(row["Formation"].ToString()); location.Create(row["Lieu"].ToString()); trainer.Create(row["Formateur"].ToString()); company.Create(row["Societe"].ToString(), row["Adresse"].ToString(), row["CP"].ToString(), row["Ville"].ToString()); student.Create(row["Stagiaire"].ToString()); contact.Create(row["Contact"].ToString(), row["Email"].ToString(), row["Telephone"].ToString(), row["Societe"].ToString()); session.Create(DateTime.Parse(row["DateFormation"].ToString()), int.Parse(row["NbJour"].ToString()), row["Formation"].ToString(), row["Formateur"].ToString(), row["Lieu"].ToString(), row["Stagiaire"].ToString(), row["Societe"].ToString()); } /* DisableAll("Formations", training.GetAll(), id => app.Command<DisableTraining>().Execute(id)); * DisableAll("Lieux", location.GetAll(), id => app.Command<DisableLocation>().Execute(id)); * DisableAll("Formateur", trainer.GetAll(), id => app.Command<DisableTrainer>().Execute(id));*/ Console.WriteLine("\r\nImport terminé !"); Console.ReadKey(); }
public void CreateTestMethod(Student student) { //arrange StudentCreator stCreator = (StudentCreator)factory.GetStudentCreator(); //act bool isCreated = stCreator.Create(student); //assert Assert.IsTrue(isCreated); }
public void shouldCreateAStudentCallingOneArgumentConstructor() { // Arrange // Act Student s = StudentCreator.Create(123); // Assert Assert.NotNull(s); Assert.AreEqual(123, s.Number); }
public void shouldCreateAStudentCallingTwoArgumentConstructor() { // Arrange // Act Student s = StudentCreator.Create(123, "Mitroglu"); // Assert Assert.NotNull(s); Assert.AreEqual(123, s.Number); Assert.AreEqual("Mitroglu", s.Name); }