Esempio n. 1
0
        public async Task Should_Success_Create_Data_GTM_AlredyExist()
        {
            TransferOutFacade   facade = new TransferOutFacade(GetServiceProvider().Object, _dbContext(GetCurrentMethod()));
            TransferStockFacade returnToCenterFacade = new TransferStockFacade(GetServiceProvider().Object, _dbContext(GetCurrentMethod()));
            var model = await dataUtil(facade, GetCurrentMethod()).GetNewDataForTransfer();

            var viewmodel = dataUtil(facade, GetCurrentMethod()).MapToViewModel(model);
            var Response  = await returnToCenterFacade.Create(viewmodel, model, USERNAME);

            Assert.NotEqual(0, Response);
        }
Esempio n. 2
0
        public async Task Should_Success_Get_Data_By_Id()
        {
            TransferOutFacade   facade = new TransferOutFacade(GetServiceProvider().Object, _dbContext(GetCurrentMethod()));
            TransferStockFacade returnToCenterFacade = new TransferStockFacade(GetServiceProvider().Object, _dbContext(GetCurrentMethod()));
            var model = await dataUtil(facade, GetCurrentMethod()).GetNewData();

            var viewmodel = dataUtil(facade, GetCurrentMethod()).MapToViewModel(model);
            await returnToCenterFacade.Create(viewmodel, model, USERNAME);

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

            Assert.NotNull(Response);
        }
        public async Task <IActionResult> Post([FromBody] TransferOutDocViewModel ViewModel)
        {
            try
            {
                identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value;

                IValidateService validateService = (IValidateService)serviceProvider.GetService(typeof(IValidateService));

                validateService.Validate(ViewModel);

                var model = mapper.Map <TransferOutDoc>(ViewModel);

                await facade.Create(ViewModel, model, identityService.Username);

                // await facade.Crea

                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.CREATED_STATUS_CODE, General.OK_MESSAGE)
                    .Ok();
                return(Created(String.Concat(Request.Path, "/", 0), Result));
            }
            catch (ServiceValidationExeption e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.BAD_REQUEST_STATUS_CODE, General.BAD_REQUEST_MESSAGE)
                    .Fail(e);
                return(BadRequest(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));
            }
        }