示例#1
0
        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));
        }
示例#2
0
        public void Add(Offering offering)
        {
            SetOfferingProperties(offering);

            ValidateOffering(offering);

            _offeringRepository.Add(offering);
        }