public async Task <Student> Update(string id, Person person) { try { var students = await _repository.Get(id); var numara = students.Number; if (students != null) { IStudentBuilder builder = new StudentBuilder(person); builder.BuildMail(); builder.BuildClass(); builder.BuildNumber((int.Parse(numara.Substring(4, 7)) - 1)); _ = await _repository.Update(id, builder.Result()); NewStudentSystemController newStudentSystemController = new NewStudentSystemController(_repositoryNewStudentSystem); _ = newStudentSystemController.Update(id, builder.Result()); } return(students); } catch (Exception) { return(null); } }
public async Task <ActionResult <Student> > Delete(string id) { var ogrenci = await _repository.Get(id); if (ogrenci == null) { return(NotFound()); } _repository.Remove(ogrenci.Id); NewStudentSystemController newStudentSystemController = new NewStudentSystemController(_repositoryNewStudentSystem); _ = newStudentSystemController.Delete(id); return(ogrenci); }
public async Task <ActionResult <Student> > Create(Person person) { try { var students = await _repository.Get(); students ??= new List <Student>(); IStudentBuilder builder = new StudentBuilder(person); builder.BuildMail(); builder.BuildClass(); builder.BuildNumber(students.Count); var student = await _repository.Create(builder.Result()); NewStudentSystemController newStudentSystemController = new NewStudentSystemController(_repositoryNewStudentSystem); _ = newStudentSystemController.Create(student); return(student); } catch (Exception) { return(UnprocessableEntity()); } }