Exemple #1
0
        public async Task <IHttpActionResult> PutCourseSections(int id, CourseSections courseSections)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != courseSections.Id)
            {
                return(BadRequest());
            }

            db.Entry(courseSections).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CourseSectionsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public virtual async Task <bool> DeleteCourseSection(CourseSections courseSectionCourseSection)
        {
            await _courseSectionRepository.Delete(_mapper.Map <LMSData.Model.CourseSections>(courseSectionCourseSection));

            await _courseSectionRepository.Save();

            return(true);
        }
        public virtual async Task <CourseSections> UpdateCourseSection(CourseSections courseSectionCourseSection)
        {
            LMSData.Model.CourseSections courseSection = _mapper.Map <LMSData.Model.CourseSections>(courseSectionCourseSection);
            await _courseSectionRepository.Update(courseSection);

            await _courseSectionRepository.Save();

            courseSectionCourseSection = _mapper.Map <Services.Model.CourseSections>(courseSection);
            return(courseSectionCourseSection);
        }
Exemple #4
0
        public async Task <IHttpActionResult> GetCourseSections(int id)
        {
            CourseSections courseSections = await db.CourseSections.FindAsync(id);

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

            return(Ok(courseSections));
        }
        public virtual async Task <CourseSections> AddCourseSection(CourseSections courseSectionCourseSection)
        {
            //save images
            LMSData.Model.CourseSections courseSection = _mapper.Map <LMSData.Model.CourseSections>(courseSectionCourseSection);

            await _courseSectionRepository.Insert(courseSection);

            await _courseSectionRepository.Save();

            courseSectionCourseSection = _mapper.Map <Services.Model.CourseSections>(courseSection);
            return(courseSectionCourseSection);
        }
Exemple #6
0
        public async Task <IHttpActionResult> PostCourseSections(CourseSections courseSections)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.CourseSections.Add(courseSections);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = courseSections.Id }, courseSections));
        }
Exemple #7
0
        public async Task <IHttpActionResult> DeleteCourseSections(int id)
        {
            CourseSections courseSections = await db.CourseSections.FindAsync(id);

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

            db.CourseSections.Remove(courseSections);
            await db.SaveChangesAsync();

            return(Ok(courseSections));
        }
        public async Task <CourseSections> UpdateSection(CourseSections courseSection)
        {
            courseSection = await sectionService.UpdateCourseSection(courseSection);

            return(courseSection);
        }
        public async Task <CourseSections> AddSection(CourseSections section)
        {
            section = await sectionService.AddCourseSection(section);

            return(section);
        }