public async Task <IActionResult> Create(DonorDto donorDto) { if (donorDto == null) { throw new ArgumentNullException(nameof(donorDto)); } if (ModelState.IsValid) { donorService.AddDonor(mapper.Map <Models.Donor>(donorDto)); await donorService.SaveChangesAsync(); return(RedirectToAction("DonorComplete")); } return(View(donorDto)); }
public async Task <ActionResult <Donors> > PostDonor(Donors donors) { try { if (donors == null) { return(BadRequest()); } var createdDonor = await donorRepository.AddDonor(donors); return(CreatedAtAction(nameof(GetDonors), new { id = createdDonor.Id }, createdDonor)); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "Error creating new Donor")); } }