public CreateClinicDto Insert(CreateClinicDto clinicDTO, string DoctorId) { if (clinicDTO == null) { throw new ArgumentNullException(); } clinicDTO.DoctorId = DoctorId; Clinic clinic = Mapper.Map <Clinic>(clinicDTO); TheUnitOfWork.ClinicRepo.Insert(clinic); TheUnitOfWork.SaveChanges(); clinicDTO.DoctorId = clinic.DoctorId; return(clinicDTO); }
public IActionResult Create(CreateClinicDto clinicDto) { if (ModelState.IsValid == false) { return(BadRequest(ModelState)); } try { var DoctorId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value; CreateClinicDto newClinicDTO = _clinicAppService.Insert(clinicDto, DoctorId); _generalAppService.CommitTransaction(); return(Created("clinic created", newClinicDTO)); } catch (Exception ex) { _generalAppService.RollbackTransaction(); return(BadRequest(ex.Message)); } }