コード例 #1
0
ファイル: CoursesController.cs プロジェクト: Mamery/Lms.Api
        public async Task <IActionResult> PutCourse(int id, Course course)
        {
            if (id != course.Id)
            {
                return(BadRequest());
            }

            uow.CourseRepository.Entry(course);



            try
            {
                // await _context.SaveChangesAsync();
                await uow.CompleteAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CourseExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #2
0
        public async Task <IActionResult> PutModule(int id, Module @module)
        {
            if (id != @module.Id)
            {
                return(BadRequest());
            }


            // _context.Entry(@module).State = EntityState.Modified;
            uow.ModuleRepository.Entry(@module);


            try
            {
                // await _context.SaveChangesAsync();
                await uow.CompleteAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ModuleExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #3
0
        public async Task <ActionResult <CourseDto> > CreateCourse(CourseDto coursesDto)
        {
            var course = mapper.Map <Course>(coursesDto);
            await uow.CourseRepository.AddAsync(course);

            await uow.CompleteAsync();

            return(CreatedAtAction("GetCourse", new { courseId = course.Id }, course));
        }
コード例 #4
0
        public async Task AddUnicorn(UnicornInput input)
        {
            var unicorn = new Unicorn {
                Color       = input.Color,
                Name        = input.Name,
                DateOfBirth = input.DateOfBirth
            };

            await _repository.InsertAsync(unicorn);

            await _uow.CompleteAsync();
        }