Пример #1
0
        public async Task <Lib.Models.UnitReceiptNoteModel.UnitReceiptNote> GetTestData(string user)
        {
            Lib.Models.UnitReceiptNoteModel.UnitReceiptNote unitReceiptNote = await GetNewData(user);

            await facade.Create(unitReceiptNote, user);

            return(unitReceiptNote);
        }
Пример #2
0
        public async Task <Lib.Models.UnitReceiptNoteModel.UnitReceiptNote> GetTestDataUrn()
        {
            var data = GetNewDataUrn();
            await UrnFacade.Create(data, "Unit Test");

            return(data);
        }
        public async Task Should_Success_Create_Having_Stock_Data()
        {
            var dbContext = _dbContext(GetCurrentMethod());
            UnitReceiptNoteFacade facade = new UnitReceiptNoteFacade(_ServiceProvider.Object, dbContext);
            var model = await _dataUtil(facade, dbContext).GetNewHavingStockData(USERNAME);

            model.IsStorage = true;
            var response = await facade.Create(model, USERNAME);

            Assert.NotEqual(response, 0);
        }
        public void Should_Success_Create_Data()
        {
            var dbContext = _dbContext(GetCurrentMethod());
            UnitReceiptNoteFacade facade = new UnitReceiptNoteFacade(_ServiceProvider.Object, dbContext);
            var model = _dataUtil(facade, dbContext).GetNewData(USERNAME).Result;

            model.IsStorage = true;
            var response = facade.Create(model, USERNAME).Result;

            Assert.NotEqual(response, 0);
        }
        public async Task Should_Success_CreateNullCOA_Data()
        {
            var dbContext = _dbContext(GetCurrentMethod());

            UnitReceiptNoteFacade facade2 = new UnitReceiptNoteFacade(GetServiceProvider2().Object, dbContext);
            var model2 = await _dataUtil(facade2, dbContext).GetNewData(USERNAME);

            model2.IsStorage = true;
            model2.UnitId    = null;
            var response2 = await facade2.Create(model2, USERNAME);

            Assert.NotEqual(response2, 0);
        }
Пример #6
0
        public async Task <IActionResult> Post([FromBody] UnitReceiptNoteViewModel vm)
        {
            identityService.Token    = Request.Headers["Authorization"].First().Replace("Bearer ", "");
            identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value;
            if (vm.supplier != null)
            {
                if (vm.no == "" || vm.no == null)
                {
                    if (vm.supplier.import == true)
                    {
                        vm.no = "BPI";
                    }
                    else
                    {
                        vm.no = "BPL";
                    }
                }
            }

            UnitReceiptNote m = _mapper.Map <UnitReceiptNote>(vm);

            ValidateService validateService = (ValidateService)_facade.serviceProvider.GetService(typeof(ValidateService));

            try
            {
                validateService.Validate(vm);

                int result = await _facade.Create(m, identityService.Username);

                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));
            }
        }
Пример #7
0
        public async Task Should_Success_Create_Data_SupplierIsImport()
        {
            var dbContext = _dbContext(GetCurrentMethod());

            UnitReceiptNoteFacade facade = new UnitReceiptNoteFacade(GetServiceProviderCurrencyNotNull(GetCurrentMethod()).Object, dbContext);
            var model = await _dataUtil(facade, dbContext, GetCurrentMethod()).GetNewData(USERNAME);

            model.IsStorage        = true;
            model.UnitId           = null;
            model.SupplierIsImport = true;

            var response = await facade.Create(model, USERNAME);

            Assert.NotEqual(0, response);
        }