public async Task <int> AddQualification(AddQualificationDto model) { Qualification qualification; if (model == null) { throw new ArgumentNullException(nameof(model)); } qualification = new Qualification { Institution = model.Institution, Certficate = model.Certficate, DateObtained = model.DateObtained }; await _schoolHubDbContext.Qualification.AddAsync(qualification); await _schoolHubDbContext.SaveChangesAsync(); //TODO: Add To Mapp var map = new StaffQualificationMap { Id = qualification.Id, StaffId = qualification.StaffId }; await _schoolHubDbContext.StaffQualificationMap.AddAsync(map); return(qualification.Id); }
public async Task <IActionResult> AddQualification([FromBody] AddQualificationDto model) { try { var staff = await _staffAppService.AddQualification(model); if (staff < 1) { return(BadRequest("Qualification could not be added")); } return(Ok(staff)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }