Пример #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));
        }
Пример #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));
        }
Пример #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));
        }
Пример #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));
        }
Пример #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));
        }