public async Task <string> CreateStudent(StudentCreateDto studentCreateDto) { var studentModel = _mapper.Map <Student>(studentCreateDto); _repository.CreateStudent(studentModel); var studentModel1 = _mapper.Map <StudentReadDto>(studentModel); HttpClient client = new HttpClient(); //ADD your ngrok url client.BaseAddress = new Uri("https://3a5e06b6ad12.ngrok.io"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); //GET Method var body = JsonConvert.SerializeObject(studentModel1, Formatting.Indented, new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.All }); var content = new StringContent(body, Encoding.UTF8, "application/json"); HttpResponseMessage response = await client.PostAsync("api/notify", content); if (response.IsSuccessStatusCode) { // Get the URI of the created resource. Uri returnUrl = response.Headers.Location; Console.WriteLine(returnUrl); } var studentReadDto = _mapper.Map <StudentReadDto>(studentModel); return("success"); }
public ActionResult <StudentReadDto> CreateStudent(StudentCreateDto studentCreateDto) { var studentModel = _mapper.Map <Student>(studentCreateDto); _repository.CreateStudent(studentModel); _repository.SaveChanges(); var studentReadDto = _mapper.Map <StudentReadDto>(studentModel); return(CreatedAtRoute(nameof(GetStudentById), new { StudentID = studentReadDto.StudentId }, studentReadDto)); }
public ActionResult <StudentReadDto> CreateStudent(StudentCreateDto std) { Student StudentModel = _mapper.Map <Student>(std); _repository.CreateStudent(StudentModel); _repository.SaveChanges(); StudentReadDto _StudentReadDto = _mapper.Map <StudentReadDto>(StudentModel); return(CreatedAtRoute(nameof(GetStudentById), new { id = _StudentReadDto.id }, _StudentReadDto)); }
public ActionResult <StudentReadDto> CreateCommand(StudentCreateDto student) { var commandModel = _mapper.Map <Student>(student); _repository.CreateStudent(commandModel); _repository.SaveChanges(); var commandReadDto = _mapper.Map <StudentReadDto>(commandModel); return(CreatedAtRoute(nameof(GetStudentById), new { Id = commandReadDto.Id }, commandReadDto)); }
public ActionResult CreateStudent(StudentCreateDto StudentCreateDto) { var StudentModel = _mapper.Map <User>(StudentCreateDto); _repo.CreateStudent(StudentModel); _repo.SaveChanges(); return(NoContent()); // return Ok(StudentModel); }
public async Task <ActionResult> CreateStudent([FromForm] StudentRequest studentRequest) { var result = await _studentRepository.CreateStudent(studentRequest); if (result.StatusCode == Helpers.Success) { return(StatusCode(StatusCodes.Status200OK, result)); } else { return(StatusCode(StatusCodes.Status400BadRequest, result)); } }
public Student CreateStudent(Student student) { return(StudentUtils.IsValidatedStudnetModel(student) ? _studentRepo.CreateStudent(student) : null); }
public void CreateStudent(Student student) { _repository.CreateStudent(student); }