Example #1
0
        public async Task <IActionResult> CreateMajor([FromBody] MajorResource majorResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var major = mapper.Map <MajorResource, Major>(majorResource);

            repository.AddMajor(major);
            await unitOfWork.Complete();

            major = await repository.GetMajor(major.MajorId);

            var result = mapper.Map <Major, MajorResource>(major);

            return(Ok(result));
        }