public IHttpActionResult Post(GroupDetailsListWithMembersDTO groupStudentMappingDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            //Mapper.CreateMap<GroupDetailsListWithMembersDTO, GroupStudentMapping>();
            //GroupStudentMapping groupStudentMapping = new GroupStudentMapping();

            //groupStudentMapping = (GroupStudentMapping)Mapper.Map(groupStudentMappingDto, groupStudentMapping, typeof(GroupDetailsListWithMembersDTO), typeof(GroupStudentMapping));

            foreach (Student stud in groupStudentMappingDto.members)
            {
                GroupStudentMapping groupStudentMapping = _unitOfWork.GroupStudentMappings.GetGroupStudentMappings().SingleOrDefault(gs => gs.GroupID == groupStudentMappingDto.group.GroupID && gs.studID == stud.studID);

                if (groupStudentMapping != null)
                {
                    _unitOfWork.GroupStudentMappings.Remove(groupStudentMapping);
                    _unitOfWork.Complete();
                    Student studForModification = _unitOfWork.Students.GetStudents().SingleOrDefault(s => s.studID == stud.studID);
                    if (studForModification != null)
                    {
                        studForModification.isAssignToGroup = true;
                        studForModification.ModifyDate      = DateTime.UtcNow;
                        _unitOfWork.Students.Update(studForModification);
                        _unitOfWork.Complete();
                    }
                    _unitOfWork.GroupStudentMappings.Add(groupStudentMapping);
                    _unitOfWork.Complete();
                    //studForModification = _unitOfWork.Students.GetStudents().SingleOrDefault(s => s.studID == stud.studID);
                    if (studForModification != null)
                    {
                        studForModification.isAssignToGroup = true;
                        studForModification.ModifyDate      = DateTime.UtcNow;
                        _unitOfWork.Students.Update(studForModification);
                        _unitOfWork.Complete();
                    }
                }
            }
            //return Created(new Uri(Request.RequestUri + "/" + groupStudentMapping.GroupID), groupStudentMappingDto);
            return(Ok("Data inserted sucessfully"));
        }
        public IHttpActionResult GetGroupStudentsByClass(int classID)
        {
            List <GroupDetails> groupDetails = _unitOfWork.GroupsDetails.GetGroupsDetails().Where(g => g.classDetails.ClassID == classID).ToList();
            List <GroupDetailsListWithMembersDTO> lstGroupDetailsListWithMembers = new List <GroupDetailsListWithMembersDTO>();

            foreach (GroupDetails gd in groupDetails)
            {
                GroupDetailsListWithMembersDTO objGroupDetailsListWithMembers = new GroupDetailsListWithMembersDTO();
                objGroupDetailsListWithMembers.group = gd;
                List <GroupStudentMapping> lstGroupStudentMapping = _unitOfWork.GroupStudentMappings.GetGroupStudentMappingsWithGroupID(gd.GroupID).ToList();
                if (lstGroupStudentMapping.Count > 0)
                {
                    objGroupDetailsListWithMembers.members = new List <Student>();
                    foreach (GroupStudentMapping obj in lstGroupStudentMapping)
                    {
                        Student objStudent = _unitOfWork.Students.Get(obj.studID);
                        objGroupDetailsListWithMembers.members.Add(objStudent);
                    }
                }
                lstGroupDetailsListWithMembers.Add(objGroupDetailsListWithMembers);
            }
            return(Ok(lstGroupDetailsListWithMembers));
        }