Exemplo n.º 1
0
        public async Task <ActionResult <Student> > UpdateCourseAsync(Guid id, Course course)
        {
            var spec = new CourseWithExamSpecification(id);
            var data = await _service.GetModelWithSpec(spec);

            if (data == null)
            {
                return(NotFound());
            }

            try
            {
                data = course;
                await _service.UpdateAsync(data);
            }
            catch (DbUpdateConcurrencyException)
            {
                var isExist = await _service.IsExists(data.Id);

                if (!isExist)
                {
                    return(NotFound());
                }
            }

            return(Ok(data));
        }
Exemplo n.º 2
0
        public async Task <ActionResult <Course> > GetByIdAsync(Guid id)
        {
            var spec = new CourseWithExamSpecification(id);
            var data = await _service.GetModelWithSpec(spec);

            if (data == null)
            {
                return(NotFound());
            }

            return(Ok(data));
        }