예제 #1
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         SupplierRegistrationInfo info = this.GetProviderInfo();
         ExistsVerifyCode();
         CompanyService.Register(info);
         this.SucceedInfo(info);
     }
     catch (ArgumentNullException ex) { this.FailInfo(ex.Message); }
     catch (InvalidOperationException ex) { this.FailInfo(ex.Message); }
     catch (Exception ex) { this.FailInfo(ex.Message); /*this.FailInfo("系统异常请稍后再试...");*/ }
 }
예제 #2
0
        /// <summary>
        /// 获取数据信息
        /// </summary>
        /// <returns></returns>
        private SupplierRegistrationInfo GetProviderInfo()
        {
            AddressInfo address = AddressInfo.GetAddress(this.hidAddress.Value);

            if (address == null)
            {
                throw new ArgumentNullException("请选择所在地");
            }
            SupplierRegistrationInfo info = new SupplierRegistrationInfo()
            {
                ProviderId      = Guid.NewGuid(),
                CompanyType     = Common.Enums.CompanyType.Supplier,
                UserName        = this.txtAccountNo.Text.Trim(),
                UserPassword    = this.txtPassWord.Text.Trim(),
                ConfirmPassword = this.txtConfirmPassWord.Text.Trim(),
                Name            = this.txtUserName.Text.Trim(),
                NickName        = this.txtPetName.Text.Trim(),
                Area            = address.AreaCode,
                Province        = address.ProvinceCode,
                City            = address.CityCode,
                District        = address.CountyCode,
                Address         = this.txtAddress.Text.Trim(),
                Contact         = this.txtLinkman.Text.Trim(),
                ContactPhone    = this.txtLinkManPhone.Text.Trim(),
                Email           = this.txtEmail.Text.Trim(),
                Faxes           = this.txtFaxes.Text.Trim(),
                MSN             = this.txtMSN.Text.Trim(),
                QQ               = this.txtQQ.Text.Trim(),
                ZipCode          = this.txtPostCode.Text.Trim(),
                HasClientType    = (HasClientType)Convert.ToInt32(this.rdolHasClientType.SelectedValue),
                PeriodStartOfUse = DateTime.Today.Date,
                PeriodEndOfUse   = DateTime.Today.AddYears(ChinaPay.B3B.Service.SystemManagement.SystemParamService.DefaultUseLimit).Date
            };
            HowToKnow howToknow = (HowToKnow)Convert.ToInt32(this.rdolHowToKnow.SelectedValue);

            if (howToknow == HowToKnow.Recommend)
            {
                info.Recommender = this.txtMarket.Text.Trim();
            }
            return(info);
        }
예제 #3
0
        public int RegisterNewSupplier(SupplierRegistrationInfo args)
        {
            var entityToAdd = new SupplierEntity()
            {
                CreatedAt   = DateTime.Now,
                Name        = args.Name,
                Surname     = args.Surname,
                PhoneNumber = args.PhoneNumber
            };

            if (this.supplierTableRepository.Contains(entityToAdd))
            {
                throw new ArgumentException("This supplier has been registered. Can't continue");
            }

            this.supplierTableRepository.Add(entityToAdd);

            this.supplierTableRepository.SaveChanges();

            return(entityToAdd.Id);
        }
        public void ShouldNotRegisterNewSupplierIfItExists()
        {
            // Arrange
            var supplierTableRepository = Substitute.For <ISupplierTableRepository>();
            SuppliersService         suppliersService = new SuppliersService(supplierTableRepository);
            SupplierRegistrationInfo args             = new SupplierRegistrationInfo();

            args.Name        = "John";
            args.Surname     = "Smith";
            args.PhoneNumber = "+73165465464";

            // Act
            suppliersService.RegisterNewSupplier(args);

            supplierTableRepository.Contains(Arg.Is <SupplierEntity>(
                                                 w => w.Name == args.Name &&
                                                 w.Surname == args.Surname &&
                                                 w.PhoneNumber == args.PhoneNumber)).Returns(true);

            suppliersService.RegisterNewSupplier(args);
        }
        public void ShouldRegisterNewSupplier()
        {
            // Arrange
            var supplierTableRepository = Substitute.For <ISupplierTableRepository>();

            supplierTableRepository
            .When(w => w.WithTransaction(Arg.Any <Action>()))
            .Do((callback) =>
            {
                callback.Arg <Action>().Invoke();
            });

            supplierTableRepository.WithTransaction <bool>(Arg.Any <Func <bool> >()).Returns((callback) =>
            {
                var result = callback.Arg <Func <bool> >().Invoke();

                return(result);
            });

            SuppliersService         suppliersService = new SuppliersService(supplierTableRepository);
            SupplierRegistrationInfo args             = new SupplierRegistrationInfo();

            args.Name        = "John";
            args.Surname     = "Smith";
            args.PhoneNumber = "+73165465464";

            // Act
            var supplierId = suppliersService.RegisterNewSupplier(args);

            // Assert
            supplierTableRepository.Received(1).Add(Arg.Is <SupplierEntity>(
                                                        w => w.Name == args.Name &&
                                                        w.Surname == args.Surname &&
                                                        w.PhoneNumber == args.PhoneNumber));
            supplierTableRepository.Received(1).SaveChanges();
        }
예제 #6
0
 /// <summary>
 /// 成功信息
 /// </summary>
 private void SucceedInfo(SupplierRegistrationInfo info)
 {
     Session["Info"] = info;
     Response.Redirect("./Succeed.aspx", false);
 }