public async Task Post([FromBody] StudentModel student) { if (string.IsNullOrEmpty(student.University) || string.IsNullOrEmpty(student.CNP)) { throw new Exception("The student does not have university or CNP set!"); } var studentEntity = new StudentEntity(student.University, student.CNP) { Email = student.Email, Faculty = student.Faculty, FirstName = student.FirstName, LastName = student.LastName, PhoneNumber = student.PhoneNumber, Year = student.Year }; // queueClient = new QueueClient(ServiceBusConnectionString, QueueName); // string json = JsonConvert.SerializeObject(student); // var message = new Message(Encoding.UTF8.GetBytes(json)); // Console.WriteLine($"Sending message: {json}"); // // Send the message to the queue. // await queueClient.SendAsync(message); using (var service = new StudentsService()) { await service.Initialize(); await service.AddStudent(studentEntity); } }
public async Task <ActionResult <IEnumerable <StudentEntity> > > Get() { using (var service = new StudentsService()) { await service.Initialize(); return(await service.GetStudents()); } }
public async Task Post([FromBody] StudentModel student) { if (string.IsNullOrEmpty(student.University) || string.IsNullOrEmpty(student.CNP)) { throw new Exception("The student does not have university or CNP set!"); } var studentEntity = new StudentEntity(student.University, student.CNP) { Email = student.Email, Faculty = student.Faculty, FirstName = student.FirstName, LastName = student.LastName, PhoneNumber = student.PhoneNumber, Year = student.Year }; using (var service = new StudentsService()) { await service.Initialize(); await service.AddStudent(studentEntity); } }