コード例 #1
0
        private async Task CreateVendorHandler(
            CreateVendorInput pComplexType)
        {
            var fCreateVendor = new Vendor
            {
                Name                   = pComplexType.Name ?? pComplexType.AdministrationCode,
                VatNumber              = string.Empty,
                CountryCode            = pComplexType.Country,
                Iban                   = pComplexType.Iban.ToList(),
                CurrencyCode           = pComplexType.Currency,
                VendorCustomerCode     = string.Empty,
                DefaultLedgerCode      = pComplexType.Ledger,
                DefaultVatCode         = pComplexType.Vat,
                DefaultVatScenarioCode = string.Empty,
                DefaultPaymentTermCode = pComplexType.Payment,
                Blocked                = false,
                Id = Guid.Empty,
                AdministrationCode = pComplexType.AdministrationCode,
                IdCompany          = pComplexType.CompanyId
            };

            var fResult = await _vendorService.CreateOrUpdate(fCreateVendor);

            //var fResult = await _vendorService.CreateOrUpdate(fCreateVendor);

            if (fResult.Object is null)
            {
                _logger.LogWarning($"Creating vendor failed with following error(s): {fResult.ErrorMessage}");
                return;
            }

            await _utilities.HandleOutput(pComplexType.Format, fResult.Object, pComplexType.Output);
        }
コード例 #2
0
        public void CreateVendor(CreateVendorInput input)
        {
            var vendor = new Vendor
            {
                VendorCode          = input.VendorCode,
                VendorName          = input.VendorName,
                VendorAddress       = input.VendorAddress,
                VendorContactEmail  = input.VendorContactEmail,
                VendorContactNumber = input.VendorContactNumber,
                VendorContactPerson = input.VendorContactPerson,
                VendorFax           = input.VendorFax,
                VendorWebsite       = input.VendorWebsite,
                VendorBankDetails   = input.VendorBankDetails,
                CreatorUserId       = input.CreatorUserId
            };

            _vendorRepository.Insert(vendor);
        }
コード例 #3
0
        public CreateVendorOutput Index([FromBody] CreateVendorInput input)
        {
            CreateVendorOutput output  = new CreateVendorOutput();
            AspUserService     aspUser = new AspUserService(_db, this);

            if (!aspUser.IsStaff)
            {
                output.Result = "NO_PRIVILEGE";
            }
            else
            {
                if (string.IsNullOrEmpty(input.Email) || string.IsNullOrEmpty(input.Name))
                {
                    output.Result = "FIELD_INCOMPLETE";
                }
                else
                {
                    User user = _db._Users.Where(e => e.Email.ToLower().Equals(input.Email)).FirstOrDefault();
                    if (user == null)
                    {
                        output.Result = "USER_NOT_FOUND";
                    }
                    else
                    {
                        Vendor vendor = new Vendor()
                        {
                            Name      = input.Name,
                            Email     = input.Email,
                            Owner     = user,
                            CreatedBy = aspUser.User.Id
                        };
                        _db.Vendors.Add(vendor);
                        user.Status = 2;
                        _db.SaveChanges();
                        output.Result = "OK";
                    }
                }
            }
            return(output);
        }