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()); }
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()); }
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)); }
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(); }