Beispiel #1
0
        public GetAllAuthorsResponse GetAllAuthors(GetAllAuthorsRequest request)
        {
            var response = new GetAllAuthorsResponse()
            {
                Request       = request,
                ResponseToken = Guid.NewGuid()
            };

            try
            {
                response.Authors = _repository.FindAll().MapToViews();
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                response.Success = false;
            }

            return(response);
        }
        public IHttpActionResult Get()
        {
            var loggedUserId = HttpContext.Current.GetOwinContext().GetUserId();

            var request = new GetAllAuthorsRequest()
            {
                RequestToken = Guid.NewGuid(),
                UserId       = loggedUserId
            };

            var authorsResponse = _authorService.GetAllAuthors(request);

            if (!authorsResponse.Success)
            {
                return(BadRequest(authorsResponse.Message));
            }

            return(Ok(
                       new
            {
                authors = authorsResponse.Authors.MapToViewModels()
            }
                       ));
        }