public StudentModel Add(StudentModel dto)
        {
            var entity  = _mapper.Map <StudentModel, Student>(dto, opt => opt.ConfigureMap().ForMember(dst => dst.Courses, m => m.Ignore()));
            var student = _studentAgent.Add(entity);

            foreach (var course in dto.Courses)
            {
                entity.Courses.Add(_mapper.Map <Course>(course));
            }
            student = _studentAgent.Update(entity);

            var studentDto = _mapper.Map <StudentModel>(student);

            return(studentDto);
        }
        public StudentModel Add(StudentModel dto)
        {
            try
            {
                var entity  = _mapper.Map <StudentModel, Student>(dto, opt => opt.ConfigureMap().ForMember(dst => dst.Courses, m => m.Ignore()));
                var student = _studentAgent.Add(entity);

                foreach (var course in dto.Courses)
                {
                    entity.Courses.Add(_mapper.Map <Course>(course));
                }
                student = _studentAgent.Update(entity);

                var studentDto = _mapper.Map <StudentModel>(student);
                return(studentDto);
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLog(ex);
            }
            return(null);
        }