public async Task <IActionResult> CreateOffering([FromBody] SaveOfferingResource offeringResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var offering = mapper.Map <SaveOfferingResource, Offering>(offeringResource); var offeringExist = repository.OfferingExist(offering); if (offeringExist) { return(Conflict("The module is already assigned to the semester")); } repository.Add(offering); await unitOfWork.CompleteAsync(); offering = await repository.GetOffering(offering.Id); var result = mapper.Map <Offering, OfferingResource>(offering); return(Ok(result)); }
public void Add(Offering offering) { SetOfferingProperties(offering); ValidateOffering(offering); _offeringRepository.Add(offering); }