public double CalculateFee(int shipperId) { //product var weight = 10; var length = 30; var width = 20; var height = 10; var product = new Product { Weight = weight, Length = length, Width = width, Height = height }; IShipper shipper = GetShipper(shipperId, product); if (shipper != null) { var result = shipper.GetFee(); return(result); } else { throw new NotImplementedException(); } }
public static IShipper Create(string companyCode) { IShipper shipper = null; if (string.IsNullOrWhiteSpace(companyCode)) { throw new ArgumentNullException("companyCode", "please input value"); } switch (companyCode) { case "1": shipper = new BlackCatShipper(); break; case "2": shipper = new HsinChuShipper(); break; case "3": shipper = new PostOfficeShipper(); break; default: shipper = null; break; } return(shipper); }
public PseudoShipperRepository() { fedEx = new Shipper("FedEx", 1, true, true, true); ups = new Shipper("UPS", 2, false, false, true); dhl = new Shipper("DHL", 3, true, true, false); }
public LogzioTarget() { var bootstraper = new Bootstraper(); bootstraper.Bootstrap(); _shipper = bootstraper.Resolve <IShipper>(); _internalLogger = bootstraper.Resolve <IInternalLogger>(); }
public int UpdateShipper(IShipper shipper) { using (IDbConnection connection = GetOpenConnection()) { string query = "UPDATE Shippers SET [Company Name] = @CompanyName WHERE [Shipper Id] = @ShipperId;"; return(connection.Execute(query, shipper)); } }
public int InsertShipper(IShipper shipper) { using (IDbConnection connection = GetOpenConnection()) { string query = "INSERT INTO Shippers ([Company Name]) VALUES (@CompanyName);"; return connection.Execute(query, shipper); } }
public int UpdateShipper(IShipper shipper) { using (IDbConnection connection = GetOpenConnection()) { string query = "UPDATE Shippers SET [Company Name] = @CompanyName WHERE [Shipper Id] = @ShipperId;"; return connection.Execute(query, shipper); } }
public int InsertShipper(IShipper shipper) { using (IDbConnection connection = GetOpenConnection()) { string query = "INSERT INTO Shippers ([Company Name]) VALUES (@CompanyName);"; return(connection.Execute(query, shipper)); } }
public void Setup() { _dummy = new LogzioListenerDummy(); _dummy.Start(); var internalLogger = new Core.InternalLogger.InternalLogger(); _shipper = new Core.Shipping.Shipper(new BulkSender(new Core.WebClient.HttpClientHandler(), false), internalLogger); }
public void Setup() { _dummy = new LogzioListenerDummy(); _dummy.Start(); var bootstraper = new Bootstraper(); bootstraper.Bootstrap(); _shipper = bootstraper.Resolve <IShipper>(); }
public void ShipperSelected() { _shipper = _repository.FindShipper(_screen.Vendor); if (_shipper != null) { PopulateScreenWithShipperOptions(); } else { RemoveShipperOptionsFromScreen(); } }
protected override void InitializeTarget() { if (_shipper == null) { if (_internalLogger == null) { _internalLogger = new InternalLoggerNLog(_shipperOptions, new Core.InternalLogger.InternalLogger()); } _shipper = new Shipper(new BulkSender(new Core.WebClient.HttpClientHandler(ProxyAddress)), _internalLogger); } _usingDefaultLayout = Layout?.ToString() == DefaultLayout; base.InitializeTarget(); }
public override void ActivateOptions() { if (_shipper == null) { if (_internalLogger == null) { _internalLogger = new InternalLoggerLog4net(_shipperOptions, new Core.InternalLogger.InternalLogger()); } _shipper = new Shipper(new BulkSender(new Core.WebClient.HttpClientHandler(_shipperOptions.BulkSenderOptions.ProxyAddress), _shipperOptions.BulkSenderOptions.JsonKeysCamelCase), _internalLogger); } base.ActivateOptions(); }
private static void EditShipper(string companyName, string newCompanyName) { System.Console.WriteLine("Editing : {0}", companyName); IShipper shipper = shipperRepository.GetShipperByName(companyName); if (shipper != null) { shipper.CompanyName = newCompanyName; int rowsAffected = shipperRepository.UpdateShipper(shipper); System.Console.WriteLine("Rows affected: {0}", rowsAffected); } }
internal static IShipper GetShipper(int company) { IShipper shipper = null; if (company == 1) // 當貨運商為黑貓時 { shipper = new Blackcat(); } else if (company == 2) // 當貨運商為新竹貨運時 { shipper = new Hsinchu(); } else if (company == 3) // 當貨運商為郵局時 { shipper = new Postoffice(); } return(shipper); }
public int InsertShipper2(IShipper shipper) { using (IDbConnection connection = GetOpenConnection()) { //SQL SERVER ONLY //string query = "INSERT INTO Shippers ([Company Name]) VALUES (@CompanyName); SELECT CAST(SCOPE_IDENTITY() as int);"; string query = "INSERT INTO Shippers ([Company Name]) VALUES (@CompanyName); SELECT CAST(@@IDENTITY as int);"; try { shipper.ShipperId = connection.Query<int>(query, shipper).Single(); } catch (Exception ex) { } if(shipper.ShipperId > 0) return 1; return 0; } }
public AdminController( IUserData userData, UserManager <User> userManager, IHostingEnvironment hostingEnvironment, ISize reposSize, IBrand reposBrand, IShipper reposShipper, IProduct reposProduct, ICategory reposCategory, ISupplier reposSupplier, IProductSize reposProductSize, IOrderDetails reposOrderDetails, IOrder reposOrder, ApplicationDbContext context, Microsoft.AspNetCore.SignalR.IHubContext <NotificationsHub> hubContext) { this.userData = userData; this.userManager = userManager; _hostingEnvironment = hostingEnvironment; _reposSize = reposSize; _reposBrand = reposBrand; _reposShipper = reposShipper; _reposProduct = reposProduct; _reposCategory = reposCategory; _reposSupplier = reposSupplier; _reposProductSize = reposProductSize; _reposOrder = reposOrder; _reposOrderDetails = reposOrderDetails; _context = context; _hubContext = hubContext; }
public int InsertShipper2(IShipper shipper) { using (IDbConnection connection = GetOpenConnection()) { //SQL SERVER ONLY //string query = "INSERT INTO Shippers ([Company Name]) VALUES (@CompanyName); SELECT CAST(SCOPE_IDENTITY() as int);"; string query = "INSERT INTO Shippers ([Company Name]) VALUES (@CompanyName); SELECT CAST(@@IDENTITY as int);"; try { shipper.ShipperId = connection.Query <int>(query, shipper).Single(); } catch (Exception ex) { } if (shipper.ShipperId > 0) { return(1); } return(0); } }
public ActionResult Index(ProductModels product) { var companies = new List <SelectListItem> { new SelectListItem { Text = "黑貓", Value = "1" }, new SelectListItem { Text = "新竹貨運", Value = "2" }, new SelectListItem { Text = "郵局", Value = "3" } }; ViewBag.Company = companies; // Validation若不合法,則直接回傳 if (!ModelState.IsValid) { return(View(product)); } double fee = 0; IShipper shipper = Factory.GetShipper(product.Company); if (shipper != null) { fee = shipper.CalculateFee(product); // 將運費結果呈現在 View 上 ViewBag.Fee = fee; } return(View(product)); }
protected void btnCalculate_Click(object sender, EventArgs e) { if (!this.IsValid) { return; } var product = this.GetShippingProduct(); var companyCode = this.drpCompany.SelectedValue; IShipper shipper = ShipperFactory.Create(companyCode); if (shipper == null) { var js = "alert('發生不預期錯誤,請洽系統管理者');location.href='http://tw.yahoo.com/';"; this.ClientScript.RegisterStartupScript(this.GetType(), "back", js, true); } else { shipper.CalculateFee(product); this.lblCompany.Text = shipper.Name; this.lblCharge.Text = product.ShippingFee.ToString(); } }
public LogzioAppender(IShipper shipper, IInternalLogger internalLogger) { _shipper = shipper; _internalLogger = internalLogger; }
public int UpdateShipper(IShipper shipper) { throw new NotImplementedException(); }
public ShipperController(IShipper ShipperService) { _ShipperService = ShipperService; }
private static void PrintShippers(IShipper shipper) { System.Console.WriteLine("ShipperId: {0} ¦ CompanyName: {1}", shipper.ShipperId, shipper.CompanyName); }
public int InsertShipper(IShipper shipper) { throw new NotImplementedException(); }
public void Setup() { _shipper = Substitute.For <IShipper>(); _target = new LogzioAppender(_shipper, Substitute.For <IInternalLogger>()); }
public LogzioTarget(IShipper shipper, IInternalLogger internalLogger) { _shipper = shipper; _internalLogger = internalLogger; }
public ShipperService(IShipper Shipper) { _Shipper = Shipper; }