public bool UpdateSubCourse(int ID, SubCourseEntity subcourseEntity)
        {
            //var success = false;

            //if (subcourseEntity != null)
            //{
            //    var Subcourse = _unitOfWork.SubcourseRepository.GetByID(ID);
            //    if (Subcourse != null)
            //    {
            //        Subcourse.Id = subcourseEntity.Id;
            //        Subcourse.Sub_Course = subcourseEntity.Sub_Course;
            //        Subcourse.CourseId = subcourseEntity.CourseId;
            //        Subcourse.Description = subcourseEntity.Description;
            //        _unitOfWork.SubcourseRepository.Update(Subcourse);
            //        _unitOfWork.Save();
            //        success = true;
            //    }
            //}
            //return success;
            var SubCourse = _mapper.Map <SubCourseEntity, SubCourse>(subcourseEntity);
            var success   = false;

            if (SubCourse != null && SubCourse.Id == ID)
            {
                if (SubCourse != null)
                {
                    _unitOfWork.SubcourseRepository.Update(SubCourse);
                    _unitOfWork.Save();
                    success = true;
                }
            }
            return(success);
        }
        public int CreateSubCourse(SubCourseEntity subcourseEntity)
        {
            var model = _mapper.Map <SubCourseEntity, SubCourse>(subcourseEntity);

            _unitOfWork.SubcourseRepository.Insert(model);
            _unitOfWork.Save();
            return(0);
        }
Beispiel #3
0
        public IActionResult Put(int id, [FromBody] SubCourseEntity subcourseEntity)
        {
            if (id == subcourseEntity.Id)
            {
                _SubcourseServices.UpdateSubCourse(id, subcourseEntity);

                return(Ok(subcourseEntity));
            }
            return(NotFound());
        }
Beispiel #4
0
 public IActionResult Post([FromBody] SubCourseEntity subCourse)
 {
     _SubcourseServices.CreateSubCourse(subCourse);
     return(Ok(subCourse));
 }