Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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();
        }