public async Task <ActionResult <PublicationViewModel> > GetPublication(
     [Required] Guid publicationId)
 {
     return(await _publicationService
            .GetPublication(publicationId)
            .HandleFailuresOrOk());
 }
        public async Task <IActionResult> GetPost(int id)
        {
            var publication = await _publicationService.GetPublication(id);

            var publicationDTO = _mapper.Map <PublicationDTO>(publication);
            var response       = new ApiResponse <PublicationDTO>(publicationDTO);

            return(Ok(response));
        }
        public async Task GetPublication_When_Valid()
        {
            //ARRANGE
            repo.Setup(x => x.GetPublication(It.IsAny <Guid>(), It.IsAny <Guid?>()))
            .ReturnsAsync((Guid value, Guid? user) =>
            {
                if (value == ExistingPublication)
                {
                    return(new PublicationViewModel());
                }
                else
                {
                    return(null);
                }
            });

            //ACT
            var result = await service.GetPublication(ExistingPublication, null);

            //ASSERT
            Assert.IsNotNull(result);
        }
Beispiel #4
0
        public async Task <IActionResult> GetPublication([FromRoute] Guid id)
        {
            try {
                var user = await HttpContext.GetUser();

                var result = await PublicationService.GetPublication(id, user?.Id);

                return(Ok(result));
            } catch (Exception ex) {
                Logger.LogWarning(ex, "An error occured: " + ex.Message ?? "undefined");
                return(ExceptionHandlerService.Handle(ex, Request));
            }
        }