Beispiel #1
0
        public async Task <IActionResult> GetAsync([FromRoute] string id,
                                                   CancellationToken cancellationToken)
        {
            if (id == null)
            {
                var error = ServiceErrorResponses.InvalidRouteParameter("EntryId");
                return(this.BadRequest(error));
            }

            var entry = await entryRepository.GetAsync(id);

            var clientEntry = EntryConverter.Convert(entry);

            return(Ok(clientEntry));
        }
Beispiel #2
0
        public async Task <IActionResult> GetAsync([FromRoute] string id, CancellationToken cancellationToken)
        {
            if (id == null)
            {
                var error = ServiceErrorResponses.InvalidRouteParameter("userId");
                return(this.BadRequest(error));
            }

            var modelUser = await userRepository.GetByIdAsync(id);

            if (modelUser == null)
            {
                var error = ServiceErrorResponses.NoSuchObject("User", "User not found");
                return(NotFound(error));
            }
            var clientUserInfo = UserConverter.ConvertToUserInfo(modelUser);

            return(Ok(clientUserInfo));
        }
Beispiel #3
0
        public async Task <IActionResult> GetAsync([FromRoute] string id, CancellationToken cancellationToken)
        {
            if (id == null)
            {
                var error = ServiceErrorResponses.InvalidRouteParameter("activityId");
                return(this.BadRequest(error));
            }

            var modelActivity = await activityRepository.GetByIdAsync(id);

            if (modelActivity == null)
            {
                var message = "Activity with id " + id + " not found.";
                var error   = ServiceErrorResponses.NoSuchObject("Activity", message);
                return(this.NotFound(error));
            }
            var clientActivity = ActivityConverter.Convert(modelActivity);

            return(Ok(clientActivity));
        }
Beispiel #4
0
        public async Task <IActionResult> GetAsync([FromRoute] string id, CancellationToken cancellationToken)
        {
            if (id == null)
            {
                var error = ServiceErrorResponses.InvalidRouteParameter("maraphoneId");
                return(this.BadRequest(error));
            }

            var modelMaraphone = await maraphoneRepository.GetAsync(id, cancellationToken);

            if (modelMaraphone == null)
            {
                var message = "Maraphone with id " + id + " not found.";
                var error   = ServiceErrorResponses.NoSuchObject("Maraphone", message);
                return(this.NotFound(error));
            }
            var clientMaraphone = MaraphoneConverter.Convert(modelMaraphone);

            return(Ok(clientMaraphone));
        }
Beispiel #5
0
        public async Task <IActionResult> GetAsync([FromRoute] string id, CancellationToken cancellationToken)
        {
            if (id == null)
            {
                var error = ServiceErrorResponses.InvalidRouteParameter("DocumentId");
                return(this.BadRequest(error));
            }

            var modelContent = await contentRepository.GetAsync(id);

            if (modelContent == null)
            {
                var error = ServiceErrorResponses.NoSuchObject("Content", "Not content with such id " + id);
                return(this.NotFound(error));
            }

            var clientContent = ContentConverter.Convert(modelContent);

            return(Ok(clientContent));
        }