コード例 #1
0
        public async Task Should_Success_Get_Data_By_Id()
        {
            TransferFacade        facade      = new TransferFacade(GetServiceProvider().Object, _dbContext(GetCurrentMethod()));
            TransferInStoreFacade facadestore = new TransferInStoreFacade(GetServiceProvider().Object, _dbContext(GetCurrentMethod()));
            var model = await dataUtil(facade, GetCurrentMethod()).GetNewData();

            await facadestore.Create(model, USERNAME);

            var Response = facadestore.ReadById((int)model.Id);

            Assert.NotNull(Response);
        }
コード例 #2
0
        public IActionResult Get(int id)
        {
            try
            {
                var model     = facade.ReadById(id);
                var viewModel = mapper.Map <TransferInDocViewModel>(model);
                if (viewModel == null)
                {
                    throw new Exception("Invalid Id");
                }

                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.OK_STATUS_CODE, General.OK_MESSAGE)
                    .Ok(viewModel);
                return(Ok(Result));
            }
            catch (Exception e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }