public IHttpActionResult GetParentById(string id) { logger.Info("Getting parent by parent ID, controller"); ParentDTOHelper parent = parentsService.GetParentById(id); return(Ok(parent)); }
public ParentDTOHelper GetParentByUserName(string username) { logger.Info("Accssesing db over Parent rep, get parent by udername"); Parent parent = db.ParentsRepository.Get(filter: x => x.UserName.Contains(username)).FirstOrDefault(); if (parent == null) { throw new ParentNotFoundException($"Parent with username {username} doesn't exist here!"); } logger.Info("converting parent with SimpleDTOConverter, get parent by username"); ParentDTOOut parentDTOOut = Utilities.ConverterDTO.SimpleDTOConverter <ParentDTOOut>(parent); IEnumerable <StudentDTOOutParent> studentDTOOutParent = parent.Students.Select(student => Utilities.ConverterDTO.StudentsDTOParentConverter(student)); ParentDTOHelper parentDTOOutHelper = new ParentDTOHelper(); parentDTOOutHelper.Parent = parentDTOOut; parentDTOOutHelper.Student = studentDTOOutParent; return(parentDTOOutHelper); }
public ParentDTOHelper GetParentById(string id) { logger.Info("Accssesing db over Parent rep, get parent by id"); Parent parent = new Parent(); parent = db.ParentsRepository.Get(filter: x => x.Id == id).FirstOrDefault(); if (parent == null) { throw new ParentNotFoundException($"Parent with ID {id} doesn't exists"); } logger.Info("converting parent with SimpleDTOConverter, get parent by id"); ParentDTOOut parentDTOOut = Utilities.ConverterDTO.SimpleDTOConverter <ParentDTOOut>(parent); IEnumerable <StudentDTOOutParent> studentDTOOutParent = parent.Students.Select(student => Utilities.ConverterDTO.StudentsDTOParentConverter(student)); ParentDTOHelper parentDTOOutHelper = new ParentDTOHelper(); parentDTOOutHelper.Parent = parentDTOOut; parentDTOOutHelper.Student = studentDTOOutParent; return(parentDTOOutHelper); }