Beispiel #1
0
        public static ParentSimpleViewDTO ParentToParentSimpleViewDTO(Parent user)
        {
            ParentSimpleViewDTO retVal = new ParentSimpleViewDTO();

            retVal.Id        = user.Id;
            retVal.FirstName = user.FirstName;
            retVal.LastName  = user.LastName;
            retVal.UserName  = user.UserName;
            retVal.Email     = user.Email;

            if (user.Students.Count < 0)
            {
                retVal.Students = null;
            }
            else
            {
                retVal.Students = user.Students.Select(child =>
                {
                    UserSimpleViewDTO dto = UserToUserSimpleViewDTO(child);
                    return(dto);
                }).ToList();
            }

            logger.Info("Convetring Parent to ParentSimpleViewDTO.");
            return(retVal);
        }
        public IHttpActionResult GetParentById(string id)
        {
            ParentSimpleViewDTO retVal = service.GetParentById(id);

            if (retVal == null)
            {
                logger.Warn($"Parent with id {id} not found.");
                return(NotFound());
            }

            logger.Info($"Getting parent with id {id}");
            return(Ok(retVal));
        }
Beispiel #3
0
        public ParentSimpleViewDTO GetParentById(string id)
        {
            Parent parent = db.ParentsRepository.Get(p => p.Id == id).FirstOrDefault();

            if (parent == null)
            {
                logger.Warn("No such parent. {0}", id);
                return(null);
            }
            logger.Info("Getting parent with id {0}", id);

            ParentSimpleViewDTO retVal = UserToUserDTOConverters.ParentToParentSimpleViewDTO(parent);

            return(retVal);
        }