예제 #1
0
        private Vendor FindOrCreateVendor(string abbr, IUnitOfWork uow)
        {
            if (_vendorAbbr.ContainsKey(abbr))
            {
                if (_vendors == null)
                {
                    _vendors = uow.VendorRepository.GetAll().ToList();
                }

                var vendor = _vendors.SingleOrDefault(v => v.Name.StartsWith(_vendorAbbr[abbr], true, CultureInfo.InvariantCulture));

                if (vendor == null)
                {
                    vendor = new Vendor
                    {
                        Name = _vendorAbbr[abbr]
                    };

                    var service = new VendorService(null, uow);
                    service.Create(vendor);
                    _vendors.Add(vendor);
                }

                return(vendor);
            }

            return(null);
        }
예제 #2
0
        public async Task <IActionResult> Create(Vendor vendor)
        {
            try
            {
                var createdVendor = await vendorServ.Create(vendor);

                return(Ok(createdVendor));
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                return(StatusCode(500));
            }
        }
예제 #3
0
        public async void Create()
        {
            var mock  = new ServiceMockFacade <IVendorRepository>();
            var model = new ApiVendorRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <Vendor>())).Returns(Task.FromResult(new Vendor()));
            var service = new VendorService(mock.LoggerMock.Object,
                                            mock.RepositoryMock.Object,
                                            mock.ModelValidatorMockFactory.VendorModelValidatorMock.Object,
                                            mock.BOLMapperMockFactory.BOLVendorMapperMock,
                                            mock.DALMapperMockFactory.DALVendorMapperMock,
                                            mock.BOLMapperMockFactory.BOLProductVendorMapperMock,
                                            mock.DALMapperMockFactory.DALProductVendorMapperMock,
                                            mock.BOLMapperMockFactory.BOLPurchaseOrderHeaderMapperMock,
                                            mock.DALMapperMockFactory.DALPurchaseOrderHeaderMapperMock);

            CreateResponse <ApiVendorResponseModel> response = await service.Create(model);

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.VendorModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiVendorRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Create(It.IsAny <Vendor>()));
        }
예제 #4
0
        public ActionResult <Vendor> Create(Vendor vendor)
        {
            _vendorService.Create(vendor);

            return(CreatedAtRoute("GetVendor", new { id = vendor.Id.ToString() }, vendor));
        }
예제 #5
0
 public ActionResult <User> CreateVendor(Vendor vendor)
 {
     _VendorService.Create(vendor);
     return(Ok());
 }