/// <summary> /// Initializes a new instance of the <see cref="BotInstance"/> class. /// </summary> /// <param name="settings">The settings.</param> public BotInstance(InstanceSettings settings) { Settings = settings; Connection = new TeamSpeakConnection(this); Repository = new DataRepository(Connection, Settings); ManagerFactory = new ManagerFactory(Repository); }
private static IManager <TaxPOCO> GetTaxManager() { return(ManagerFactory.GetInstance().GetManagerFor <TaxPOCO>()); }
private static IManager <ClientTypePOCO> GetClientTypeManager() { return(ManagerFactory.GetInstance().GetManagerFor <ClientTypePOCO>()); }
public void Execute() { Manager manage = ManagerFactory.Create(); Console.Clear(); Console.WriteLine(bar); Console.WriteLine("QB Rating Calculator"); Console.WriteLine("Calculate Player"); Console.WriteLine(bar); Calculations calc = new Calculations(); Player player = new Player(); player.Name = ConsoleIO.GetPlayerName("Please enter the Quarterback's Name (I.E. Steve Young): "); player.PassAttempted = ConsoleIO.GetPassAttempt($"Please enter passing attempt of {player.Name}: "); do { player.PassCompleted = ConsoleIO.GetPassComplete($"Please enter passing completion of {player.Name}: "); if (player.PassCompleted > player.PassAttempted) { Console.WriteLine("Completions must be less than Attempts..."); Console.WriteLine("Press any key to continue..."); Console.ReadLine(); } } while (player.PassCompleted > player.PassAttempted); player.PassingYard = ConsoleIO.GetPassYard($"Please enter the passing yard of {player.Name}: "); do { player.PassingTD = ConsoleIO.GetPassTD($"Please enter the amount of touchdowns {player.Name} has thrown or scored: "); if (player.PassingTD > player.PassCompleted) { Console.WriteLine("Touchdowns must be less than passing completions..."); Console.WriteLine("Press any key to continue..."); Console.ReadLine(); } } while (player.PassingTD > player.PassCompleted); do { player.Interceptions = ConsoleIO.GetPassInt($"Please enter the number of interceptions for {player.Name}: "); if (player.Interceptions > player.PassAttempted - player.PassCompleted) { Console.WriteLine("Interceptions must be less than passes attempts minus passes completed..."); Console.WriteLine("Press any key to continue..."); Console.ReadLine(); } } while (player.Interceptions > player.PassAttempted - player.PassCompleted); calc.CalcRating(player); ConsoleIO.DisplayPlayer(player); var saveStats = ConsoleIO.SaveStats($"Press Y to save stats, else press any other key..."); Console.WriteLine("Press any key to continue..."); if (saveStats) { manage.AddManager(player); } Console.ReadLine(); }
private static IManager <ProviderPOCO> GetProviderManager() { return(ManagerFactory.GetInstance().GetManagerFor <ProviderPOCO>()); }
/// <summary> /// Gets factory initialized by the id_token. /// </summary> /// <param name="ecommerceContext">The eCommerce context.</param> /// <returns>The factory.</returns> public static ManagerFactory GetManagerFactory(EcommerceContext ecommerceContext) { if (ecommerceContext == null) { throw new ArgumentNullException(nameof(ecommerceContext)); } if (string.IsNullOrEmpty(ecommerceContext.OperatingUnitId)) { RetailLogger.Log.OnlineStoreOperatingUnitNumberNotSetInEcommerceContext(); var exception = new NotSupportedException("The operating unit number must be set in the eCommerce context."); throw exception; } Uri retailServerUri = null; OperatingUnitConfiguration operatingUnitConfig = null; if (!cachedOperatingUnitConfig.TryGetValue(ecommerceContext.OperatingUnitId, out operatingUnitConfig)) { lock (syncRoot) { if (!cachedOperatingUnitConfig.TryGetValue(ecommerceContext.OperatingUnitId, out operatingUnitConfig)) { retailServerUri = new Uri(ConfigurationManager.AppSettings["RetailServerRoot"]); operatingUnitConfig = new OperatingUnitConfiguration() { RetailServerUri = retailServerUri }; cachedOperatingUnitConfig.Add(ecommerceContext.OperatingUnitId, operatingUnitConfig); } } } else { retailServerUri = operatingUnitConfig.RetailServerUri; } ManagerFactory managerFactory = null; RetailServerContext context = null; if (string.IsNullOrEmpty(ecommerceContext.AuthenticationToken)) { context = RetailServerContext.Create(retailServerUri, ecommerceContext.OperatingUnitId); } else { if (ecommerceContext.IdentityProviderType == IdentityProviderType.OpenIdConnect) { context = RetailServerContext.Create(retailServerUri, ecommerceContext.OperatingUnitId, ecommerceContext.AuthenticationToken); } else if (ecommerceContext.IdentityProviderType == IdentityProviderType.ACS) { context = RetailServerContext.Create(retailServerUri, ecommerceContext.OperatingUnitId, new AcsToken(ecommerceContext.AuthenticationToken)); } else { RetailLogger.Log.OnlineStoreUnsupportedIdentityProviderTypeEncountered(ecommerceContext.IdentityProviderType.ToString()); string message = string.Format("The specified identity provider type [{0}] set in the eCommerce context is not supported.", ecommerceContext.IdentityProviderType); var exception = new NotSupportedException(message); throw exception; } } context.Locale = ecommerceContext.Locale; managerFactory = ManagerFactory.Create(context); return(managerFactory); }
public ActionResult AddVehicle(AddVehicleVM vm) { var manager = ManagerFactory.Create(); if (vm.Year < 2000 || vm.Year > DateTime.Now.Year + 1) { ModelState.AddModelError("", "Error: Vehicle year must be between 2000 and " + (DateTime.Now.Year + 1) + "."); } if (manager.GetCondition(vm.SelectedConditionId).Name == "New" && vm.Mileage > 1000) { ModelState.AddModelError("", "Error: If condition is set to new, mileage must be less than 1,000."); } if (manager.GetCondition(vm.SelectedConditionId).Name == "Used" && vm.Mileage <= 1000) { ModelState.AddModelError("", "Error: If condition is set to used, mileage must be greater than 1,000."); } if (vm.VIN == "") { ModelState.AddModelError("", "Error: VIN cannot be blank."); } if (vm.MSRP <= 0) { ModelState.AddModelError("", "Error: MSRP must be greater than 0."); } if (vm.SalePrice <= 0) { ModelState.AddModelError("", "Error: sale price must be greater than 0."); } if (vm.SalePrice > vm.MSRP) { ModelState.AddModelError("", "Error: Sale price must be lower than MSRP."); } if (vm.Description == "") { ModelState.AddModelError("", "Error: A description is required."); } if (!ModelState.IsValid) { vm.SetAllLists(manager); return(View(vm)); } else { Vehicle toAdd = new Vehicle { BodyStyle = manager.GetBodyStyle(vm.SelectedStyleId), ConditionType = manager.GetCondition(vm.SelectedConditionId), Description = vm.Description, ExteriorColor = manager.GetColor(vm.SelectedColorId), InteriorColor = manager.GetColor(vm.SelectedColorId), Mileage = vm.Mileage, ModelType = manager.GetModel(vm.SelectedModelId), MSRP = vm.MSRP, SalePrice = vm.SalePrice, Trans = manager.GetTransmission(vm.SelectedTransId), VIN = vm.VIN, Year = vm.Year, IsFeatured = false //picture path }; var saved = manager.AddVehicle(toAdd); string dir = Server.MapPath("~/Images"); vm.Picture.SaveAs(Path.Combine(dir, "inventory-" + saved.Id.ToString() + ".jpg")); saved.PicturePath = "~/Images/" + "inventory-" + saved.Id.ToString() + ".jpg"; manager.EditVehicle(saved); return(RedirectToAction("Vehicles")); } }
public new void TestFixtureSetUp() { PlaylistItemController = new PlaylistItemController(Logger, Session, ManagerFactory); UserController = new UserController(Logger, Session, ManagerFactory); UserManager = ManagerFactory.GetUserManager(Session); }
public BaseService() { Factory = new ManagerFactory(); }
//Questions/Concerns //================================= //Order Confirmation - Do I need a response object in case order creation in manager fails? //--If so, what to catch? public void Execute() { Manager manager = ManagerFactory.Create(); string productType = ""; string stateAbbreviation = ""; ConsoleIO.Clear(); ConsoleIO.GeneralPrompt("Add Order"); ConsoleIO.SeperatorBar(); DateTime orderDate = ConsoleIO.RetrieveOrderDateFromUser("Enter an order date (Format: MM/DD/YYYY): "); ConsoleIO.BlankLine(); string customerName = ConsoleIO.RetrieveCustomerNameFromUser("Enter a customer name: "); while (true) { ConsoleIO.Clear(); ConsoleIO.GeneralPrompt("Available States"); ConsoleIO.SeperatorBar(); ConsoleIO.BlankLine(); DisplayStatesResponse response = manager.DisplayStateList(); if (response.Success) { ConsoleIO.DisplayListOfStates(response.States); } else { ConsoleIO.BlankLine(); ConsoleIO.GeneralPrompt("An error occurred."); ConsoleIO.GeneralPrompt(response.Message); } stateAbbreviation = ConsoleIO.RetrieveStateAbbreviationFromUser("Enter a state abbreviation (Example: PA): "); StateCheckResponse stateCheckResponse = manager.StateCheckAbbreviationEntry(stateAbbreviation); if (stateCheckResponse.Success) { break; } else { ConsoleIO.BlankLine(); ConsoleIO.GeneralPrompt("An error occurred."); ConsoleIO.GeneralPrompt(stateCheckResponse.Message); ConsoleIO.ReadKeyPlusPrompt("Press any key to try again..."); } } //Product Type while (true) { ConsoleIO.Clear(); ConsoleIO.GeneralPrompt("Available Products"); ConsoleIO.SeperatorBar(); ConsoleIO.BlankLine(); DisplayProductsResponse response = manager.DisplayProductList(); if (response.Success) { ConsoleIO.DisplayListOfProducts(response.Products); } else { ConsoleIO.BlankLine(); ConsoleIO.GeneralPrompt("An error occurred."); ConsoleIO.GeneralPrompt(response.Message); } ConsoleIO.GeneralPrompt("Enter a Product Type (Carpet, Laminate, Tile, Wood)"); ConsoleIO.BlankLine(); productType = ConsoleIO.RetrieveProductTypeFromUser("(WARNING: Case Sensitive Entry): "); CheckProductResponse checkProductResponse = manager.CheckProductTypeEntry(productType); if (checkProductResponse.Success) { break; } else { ConsoleIO.BlankLine(); ConsoleIO.GeneralPrompt("An error occurred."); ConsoleIO.GeneralPrompt(checkProductResponse.Message); continue; } } //Area ConsoleIO.BlankLine(); decimal area = ConsoleIO.RetrieveAreaSizeFromUser("Enter an area size (Minimum Amount = 100): "); //Display Order ConsoleIO.Clear(); ConsoleIO.GeneralPrompt("Here is your order:"); ConsoleIO.BlankLine(); Order orderToCreate = manager.CreateNewOrder(orderDate, customerName, stateAbbreviation, productType, area); ConsoleIO.DisplaySingleOrder(orderToCreate); //Confirm Add Order ConsoleIO.GeneralPrompt("Order Confirmation"); ConsoleIO.SeperatorBar(); bool addOrderConfirmation = ConsoleIO.Confirmation("Are you sure you would like to create the above order? (Enter Y/N): "); if (addOrderConfirmation == true) { manager.AddOrder(orderToCreate); ConsoleIO.BlankLine(); ConsoleIO.GeneralPrompt("Your order has been added to the system."); } else { ConsoleIO.GeneralPrompt("Order Creation Canceled."); ConsoleIO.BlankLine(); } ConsoleIO.ReadKeyPlusPrompt("Press any key to continue..."); }
public void OnClickMainMenu() { ManagerFactory.Get <SceneLoadManager>().LoadSceneAsync(GlobalConstants.MenuScene); }
public void Restart() { ManagerFactory.Get <SceneLoadManager>().LoadSceneAsync(GlobalConstants.GameplayScene); ManagerFactory.Clear(); }
/// <summary> /// 审批流程的一步步封装 /// /// 行为型设计模式的巅峰之作:责任链模式Respon /// </summary> public static void AdultShow() { ApplyContext context = new ApplyContext() { Id = 101, Name = "卯金刀", Hour = 30, AdultResult = false }; //方法五//工厂方法模式 就是为了扩展 为了屏蔽细节 { IFactory factory = new PMFactoryChild();//new PMFactory(); 包一层child就是为了进一步扩展 AbstractAdult PM = factory.CreateInstance(); factory = new ChargerFactory(); AbstractAdult Charger = factory.CreateInstance(); factory = new ManagerFactory(); AbstractAdult Manager = factory.CreateInstance(); //以上的创建对象还可以不用new ,可以用创建型设计模式 中的简单工厂 工厂方法 抽象工厂 PM.SetNext(Charger); Charger.SetNext(Manager); //PM.SetNext(Manager);//保证环节的稳定、可以灵活的配置 PM.Adult(context); } //方法四 简单工厂 //{ // AbstractAdult PM = SimpleFactory.CreateInstance(SimpleFactory.AdultType.PM); // AbstractAdult Charger = SimpleFactory.CreateInstance(SimpleFactory.AdultType.Charger); // AbstractAdult Manager = SimpleFactory.CreateInstance(SimpleFactory.AdultType.Manager); // //以上的创建对象还可以不用new ,可以用创建型设计模式 中的简单工厂 工厂方法 抽象工厂 // PM.SetNext(Charger); // Charger.SetNext(Manager); // //PM.SetNext(Manager);//保证环节的稳定、可以灵活的配置 // PM.Adult(context); //} //方法三 //{ // AbstractAdult PM = new PM() // { // Name = "张三组长" // }; // AbstractAdult Charger = new Charger() // { // Name = "李四主管" // }; // AbstractAdult Manager = new Manager() // { // Name = "王五经理" // }; // //以上的创建对象还可以不用new ,可以用创建型设计模式 中的简单工厂 工厂方法 抽象工厂 // //PM.SetNext(Charger); // //Charger.SetNext(Manager); // PM.SetNext(Manager);//保证环节的稳定、可以灵活的配置 // PM.Adult(context); //} //方法二 抽象父类 面向对象第一步 多态、封装、继承都有 //{ // AbstractAdult PM = new PM() // { // Name = "张三组长" // }; // PM.Adult(context); // if (!context.AdultResult) // { // AbstractAdult Charger = new Charger() // { // Name = "李四主管" // }; // Charger.Adult(context); // if (!context.AdultResult) // { // AbstractAdult Manager = new Manager() // { // Name = "王五经理" // }; // Manager.Adult(context); // } // } //} //方法一(最简单,不涉及面向对象封装) //{ // //面向过程编程 // if (context.Hour < 8) // { // Console.WriteLine("PM审批通过"); // } // else if (context.Hour < 16) // { // Console.WriteLine("主管审批通过"); // } // else { // Console.WriteLine("……"); // } //} }
public IHttpActionResult VehiclesBySearch(string searchTerm, decimal minPrice, decimal maxPrice, int minYear, int maxYear, string searchType) { var manager = ManagerFactory.Create(); var searchResult = new List <Vehicle>(); if (searchTerm == "Enter make, model, or year") { searchTerm = ""; } using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = @"Server=localhost;Database=SG_Dealership;Trusted_Connection=yes;"; var cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "SELECT Vehicles.PicturePath, Vehicles.Id VehicleId, Vehicles.Mileage, Vehicles.VIN, Vehicles.SalePrice, Vehicles.MSRP, Models.Id ModelId, Vehicles.Year VehicleYear, c.Id ExtColorId, ic.Id IntColorId, Styles.Id BodyStyleId, Transmissions.Id TransId, Conditions.Id ConditionId" + " FROM Vehicles" + " INNER JOIN Colors c ON Vehicles.ExteriorColor_Id = c.Id" + " INNER JOIN Colors ic ON Vehicles.InteriorColor_Id = ic.Id" + " INNER JOIN Transmissions ON Vehicles.Trans_Id = Transmissions.Id" + " INNER JOIN Styles ON Vehicles.BodyStyle_Id = Styles.Id" + " INNER JOIN Models ON Vehicles.ModelType_Id = Models.Id" + " INNER JOIN Makes ON Makes.Id = Models.Maker_Id" + " INNER JOIN Conditions ON Vehicles.ConditionType_Id = Conditions.Id" + " WHERE (Vehicles.SalePrice > @minPrice AND Vehicles.SalePrice < @maxPrice)" + " AND (Vehicles.Year >= @minYear AND Vehicles.Year <= @maxYear)" + " AND (Makes.Name LIKE Concat('%', @searchTerm, '%') OR Models.Name LIKE Concat('%', @searchTerm, '%') OR Vehicles.Year LIKE Concat('%', @searchTerm, '%'))"; cmd.Parameters.AddWithValue("@minPrice", minPrice); cmd.Parameters.AddWithValue("@maxPrice", maxPrice); cmd.Parameters.AddWithValue("@minYear", minYear); cmd.Parameters.AddWithValue("@maxYear", maxYear); cmd.Parameters.AddWithValue("@searchTerm", searchTerm); conn.Open(); using (var dr = cmd.ExecuteReader()) { while (dr.Read()) { Vehicle v = new Vehicle(); v.Id = (int)dr["VehicleId"]; v.Mileage = (int)dr["Mileage"]; v.VIN = dr["VIN"].ToString(); v.SalePrice = (decimal)dr["SalePrice"]; v.MSRP = (decimal)dr["MSRP"]; v.ModelType = manager.GetModel((int)dr["ModelId"]); v.Year = (int)dr["VehicleYear"]; v.ExteriorColor = manager.GetColor((int)dr["ExtColorId"]); v.InteriorColor = manager.GetColor((int)dr["IntColorId"]); v.BodyStyle = manager.GetBodyStyle((int)dr["BodyStyleId"]); v.ConditionType = manager.GetCondition((int)dr["ConditionId"]); v.Trans = manager.GetTransmission((int)dr["TransId"]); v.PicturePath = dr["PicturePath"].ToString(); if (!manager.GetAllSales().Any(s => s.PurchasedVehicle.Id == v.Id)) { switch (searchType) { case "New": switch (v.ConditionType.Name) { case "New": searchResult.Add(v); break; default: break; } break; case "Used": switch (v.ConditionType.Name) { case "Used": searchResult.Add(v); break; default: break; } break; case "NewUsed": searchResult.Add(v); break; default: break; } } } } } return(Ok(searchResult)); }
private void button1_Click(object sender, EventArgs e) { IQueryManager iqm = ManagerFactory.getQueryManager("QUeryManagerImpl"); int id = int.Parse(Memberid.Text); int index; Member member = new Member(); Member m = null; m = iqm.queryMember(id); if (m == null) { MessageBox.Show("该成员不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } int[] fatherid = iqm.getRelativeId(1, id); int[] brotherid = iqm.getRelativeId(2, id); Partner mother = iqm.getMother(id); int[] systerid = iqm.getRelativeId(3, id); dgv.Rows.Clear(); for (int i = 0; i < fatherid.Length; i++) { if (fatherid[i] == 0) { continue; } index = dgv.Rows.Add(); member = iqm.queryMember(fatherid[i]); dgv.Rows[index].Cells[0].Value = member.Name; dgv.Rows[index].Cells[1].Value = member.Sex; dgv.Rows[index].Cells[2].Value = member.Generation; dgv.Rows[index].Cells[3].Value = member.Birth; dgv.Rows[index].Cells[4].Value = "父子"; dgv.Rows[index].Cells[5].Value = member.Idcard; } if (mother != null) { index = dgv.Rows.Add(); dgv.Rows[index].Cells[0].Value = mother.Name; dgv.Rows[index].Cells[1].Value = mother.Sex; dgv.Rows[index].Cells[2].Value = "无"; dgv.Rows[index].Cells[3].Value = "无"; dgv.Rows[index].Cells[4].Value = "母子"; dgv.Rows[index].Cells[5].Value = "无"; } for (int i = 0; i < brotherid.Length; i++) { if (brotherid[i] == 0) { continue; } index = dgv.Rows.Add(); member = iqm.queryMember(brotherid[i]); dgv.Rows[index].Cells[0].Value = member.Name; dgv.Rows[index].Cells[1].Value = member.Sex; dgv.Rows[index].Cells[2].Value = member.Generation; dgv.Rows[index].Cells[3].Value = member.Birth; dgv.Rows[index].Cells[4].Value = "兄弟姐妹"; dgv.Rows[index].Cells[5].Value = member.Idcard; } for (int i = 0; i < systerid.Length; i++) { if (systerid[i] == 0) { continue; } member = iqm.queryMember(systerid[i]); index = dgv.Rows.Add(); dgv.Rows[index].Cells[0].Value = member.Name; dgv.Rows[index].Cells[1].Value = member.Sex; dgv.Rows[index].Cells[2].Value = member.Generation; dgv.Rows[index].Cells[3].Value = member.Birth; dgv.Rows[index].Cells[4].Value = "兄弟姐妹"; dgv.Rows[index].Cells[5].Value = member.Idcard; } }
static void Main(string[] args) { var managerFactory = new ManagerFactory(new AmbientContext()); var calculationManager = managerFactory.Create <ICalculationManager>(); var instanceId = Guid.NewGuid(); var currentTotal = new CalculatorData() { InstanceId = instanceId }; var memoryTotal = new CalculatorData() { InstanceId = instanceId }; double operand1 = 2.0006D; double operand2 = 3D; // Add two numbers Console.WriteLine($"Calculating {operand1} + {operand2}"); var calculatorRequest = new CalculationRequest() { InstanceId = instanceId, Operand1 = operand1, Operand2 = operand2, Operator = "+" }; var result = calculationManager.GetCalculationResult(calculatorRequest); // Get Total From Storage Console.WriteLine("Retrieving Total from storage"); currentTotal = calculationManager.LoadTotal(currentTotal); Console.WriteLine($"Total from storage: {currentTotal.Value}"); Debug.Assert(currentTotal.InstanceId == instanceId); Debug.Assert(currentTotal.Value.CompareTo(operand1 + operand2) == 0); // Store Total to Memory Console.WriteLine("Storing Total to memory"); calculationManager.StoreToMemory(currentTotal); // Retrieve From Memory Console.WriteLine("Retreiving Total to memory"); memoryTotal = calculationManager.RetrieveFromMemory(memoryTotal); Debug.Assert(memoryTotal.InstanceId == instanceId); Debug.Assert(memoryTotal.Value.CompareTo(currentTotal.Value) == 0); // Clear Memory Console.WriteLine("Clearing memory"); calculationManager.ClearMemory(memoryTotal); // Clear Total From Storage Console.WriteLine("Clearing total storage"); calculationManager.ClearTotal(new CalculatorData() { InstanceId = instanceId }); Console.WriteLine("Press Enter to close"); Console.ReadLine(); }
public ActionResult Purchase(PurchaseVM vm) { var manager = ManagerFactory.Create(); vm.Vehicle = manager.GetVehicle(vm.Vehicle.Id); if (vm.Email == null && vm.Phone == null) { ModelState.AddModelError("", "Either Email or Phone must be provided."); } decimal minPurchasePrice = vm.Vehicle.SalePrice * .95M; if (vm.PurchasePrice < minPurchasePrice) { ModelState.AddModelError("", $"Purchase price cannot be less than 95% of the sales price ({string.Format("{0:C}", minPurchasePrice)})."); } if (!ModelState.IsValid) { vm.SetListItems(manager); return(View(vm)); } else { if (vm.Vehicle.IsFeatured) { manager.RemoveFromFeatured(vm.Vehicle); } var address = new Address { City = vm.City, CustState = manager.GetState(vm.SelectedStateId), Street1 = vm.Street1, ZipCode = vm.Zipcode }; if (vm.Street2 != null) { address.Street2 = vm.Street2; } var customer = new Customer(); var existingCustomer = manager.GetAllCustomers() .Where(c => c.Name == vm.Name && c.CustAddress.CustState.Id == address.CustState.Id && c.CustAddress.City == address.City && c.CustAddress.Street1 == address.Street1 && c.CustAddress.ZipCode == address.ZipCode).ToList().SingleOrDefault(); if (existingCustomer != null) { customer = existingCustomer; } else { customer = new Customer { Name = vm.Name, CustAddress = address, }; if (vm.Email != null) { customer.Email = vm.Email; } if (vm.Phone != null) { customer.Phone = vm.Phone; } } var userManager = new UserManager <AppUser>(new UserStore <AppUser>(new EntityRepo())); var userId = userManager.FindByName(User.Identity.Name).Id; AppUser currentUser = userManager.FindById(userId); var sale = new Sale { Employee = currentUser, Buyer = customer, Price = vm.PurchasePrice, PurchasedVehicle = vm.Vehicle, SaleDate = DateTime.Now, SaleType = manager.GetPurchaseType(vm.SelectedPurchaseTypeId) }; manager.AddSale(sale); return(RedirectToAction("Index", "Sales")); } }
public void SetupContext() { UserManager = ManagerFactory.GetUserManager(Session); }
public ManagerTestBase() { ManagerFactory = new ManagerFactory(Context); PlanningManager = ManagerFactory.CreateManager <IPlanningManager>(); }
public Processor(ManagerFactory factory, IEnumerable<IProvider> providers) { myManagers = providers.Select(provider => factory.Create<T>(provider).ToList(); }
/// <summary> /// Executes the sequence. /// </summary> /// <param name="ui">The Floor Manager UI instance</param> /// <param name="output">Output class instance</param> /// <param name="input">Input class instance</param> public void Execute(FlooringOrders ui, Output output, Input input) { string dateInput = string.Empty, customerName = string.Empty, state = string.Empty, productType = string.Empty; int orderNumber = 0; decimal area = 0; Console.Clear(); Console.WriteLine("*** Edit Order **"); //Prompt user to input a date dateInput = input.PromptUser("Please enter the Date of the order (mm/dd/yyyy)"); Manager manager = ManagerFactory.Create(dateInput); Response dateResponse = manager.ValidDate(manager.OrderRepository.OrderDate); //Check if the entered date is a valid entry, if not send an error if (dateResponse.ResponseType == ResponseType.Invalid) { output.SendError("Invalid date input."); return; } //Check if the entered date is later than today's if (!(dateResponse.Date > DateTime.Now.Date)) { output.SendError($"Date must be later than today's date: {DateTime.Today.Date:MM/dd/yyyy}"); return; } Console.Clear(); //Checks if the order repository for the inputted date contains any values if (manager.OrderRepository.Data.Count <= 0) { //If not, then the file should not exist. FileManager.DeleteFile(FileManager.OrdersPath, dateResponse.Date); output.SendTimedMessage("There are no orders to display.", ConsoleColor.Yellow, 1.5d); //Delete the file & return to main menu. ui.State = UIState.Options; output.ShowFooter("Press any key to go back..."); return; } //Show the user the current order data output.DisplayOrderData(manager.OrderRepository.Data, dateResponse.Date); Order order = new Order(); //Prompt the user for an order number until valid while (orderNumber == 0) { //Prompt user for an order number string orderNumberInput = input.PromptUser("Please enter the order number you'd like to edit."); //Check if string can be parsed as numeric value, and set the order number if (!int.TryParse(orderNumberInput, out orderNumber)) { output.SendError("You can only enter numeric values for an order number."); continue; } order = manager.OrderRepository.GetByValue(orderNumber); //Check if an order exists for that order number if (order == null) { output.SendError("No orders found."); orderNumber = 0; } } //Prompt user to change the customer name while (string.IsNullOrEmpty(customerName)) { customerName = input.PromptUser($"Edit current customer name? [{order.CustomerName}]"); //If the user hits enter, the state returns to default if (string.IsNullOrEmpty(customerName)) { break; } //If the name is invalid, set the customer name to default and continue prompt if (!input.ValidName(customerName)) { output.SendError("Invalid customer name. Check special characters."); customerName = string.Empty; } } //Prompt the user to edit the current state until some response is inputted while (string.IsNullOrEmpty(state)) { Console.WriteLine($"Edit current state? [{order.TaxData.State}]" + "\n"); //Compile list of states for user to choose from state = new ChooseStateWorkflow().GetValue(output, input, manager); //If the user hits enter, the state returns to default if (string.IsNullOrEmpty(state)) { state = order.TaxData.State; } } //Prompt the user to edit the current product type until a response while (string.IsNullOrEmpty(productType)) { Console.WriteLine($"Edit current product type? [{order.Product.ProductType}]" + "\n"); //Compile list of product types for user to choose from productType = new ChooseProductWorkflow().GetProduct(output, input, manager); //If the user hits enter, the product type returns to default if (string.IsNullOrEmpty(productType)) { productType = order.Product.ProductType; } } Console.WriteLine($"Edit current area? [{order.Area}]"); //Prompt the user to enter the area in sq ft until conditions are met while (area < 100) { string areaInput = input.PromptUser("Please enter the new area: "); //No input or hit enter - set area to original value if (string.IsNullOrEmpty(areaInput)) { area = order.Area; break; } if (!decimal.TryParse(areaInput, out area)) { output.SendError("Could not parse input as decimal."); continue; } if (area < 0) { output.SendError("Area must be a positive decimal."); continue; } } //Properly set any data that may be invalid string finalCustomerName = string.IsNullOrEmpty(customerName) ? order.CustomerName : customerName; string finalState = string.IsNullOrEmpty(state) ? order.TaxData.State : state; string finalProductType = string.IsNullOrEmpty(productType) ? order.Product.ProductType : productType; decimal finalArea = ((area != order.Area) && (area != 0 && area >= 100)) ? area : order.Area; //Attempt to edit the order & return a response EditOrderResponse response = manager.EditOrder(dateInput, order.OrderNumber, finalCustomerName, finalState, finalProductType, finalArea); ui.State = UIState.Options; //If the response fails, send the error & return to menu if (response.ResponseType == ResponseType.Fail || response.ResponseType == ResponseType.Invalid) { output.SendError(response.Message); return; } Console.Clear(); //Display data, show footer & wait for input to return to menu output.DisplayOrderData(response.NewOrder, response.Date); output.SendTimedMessage("Order edited successfully!", ConsoleColor.Green, 1D); output.ShowFooter("Press any key to continue..."); }
private static IManager <ProductFamilyPOCO> GetProductFamilyManager() { return(ManagerFactory.GetInstance().GetManagerFor <ProductFamilyPOCO>()); }
public new void TestFixtureSetUp() { PlaylistManager = ManagerFactory.GetPlaylistManager(Session); User = Helpers.CreateUser(); }
public void Execute() { Manager manager = ManagerFactory.Create(); ConsoleIO.Clear(); ConsoleIO.GeneralPrompt("Edit Order"); ConsoleIO.SeperatorBar(); DateTime orderDate = ConsoleIO.RetrieveOrderDateFromUser("Enter an order date (Format: MM/DD/YYYY): "); int orderNumber = ConsoleIO.RetrieveOrderNumberFromUser("Enter an order number: "); OrderResponse originalOrderResponse = manager.RetrieveOrder(orderDate, orderNumber);//ORIGiNAL/UNTOUCHED ORDER!!!!!!!!! //Check for existence of order if (originalOrderResponse.Success) { ConsoleIO.DisplaySingleOrder(originalOrderResponse.Order); } else { ConsoleIO.GeneralPrompt("An error occurred."); ConsoleIO.GeneralPrompt(originalOrderResponse.Message); } //Customer Name ConsoleIO.GeneralPrompt("Enter a new customer name or press enter to continue: "); string updatedCustomerName = Console.ReadLine(); if (string.IsNullOrEmpty(updatedCustomerName)) { updatedCustomerName = originalOrderResponse.Order.CustomerName;//If nothing entered, leave customer name the same } //State string updatedStateAB = ""; while (true) { ConsoleIO.Clear(); ConsoleIO.GeneralPrompt("Available States"); ConsoleIO.SeperatorBar(); ConsoleIO.BlankLine(); DisplayStatesResponse response = new DisplayStatesResponse(); response = manager.DisplayStateList(); if (response.Success) { ConsoleIO.DisplayListOfStates(response.States); } else { ConsoleIO.BlankLine(); ConsoleIO.GeneralPrompt("An error occurred."); ConsoleIO.GeneralPrompt(response.Message); } //Attempted to put in IO, not sure how. Problem: need to return string but one possible user submission is emptry string ConsoleIO.GeneralPrompt("Enter a new state abbreviation OR press enter to continue: "); updatedStateAB = Console.ReadLine().ToUpper(); if (string.IsNullOrEmpty(updatedStateAB)) { updatedStateAB = originalOrderResponse.Order.State; break; } else if (updatedStateAB.Length != 2) { ConsoleIO.GeneralPrompt("Error. State abbreviations must be 2 characters in length."); continue; } StateCheckResponse stateCheckResponse = new StateCheckResponse(); stateCheckResponse = manager.StateCheckAbbreviationEntry(updatedStateAB); if (stateCheckResponse.Success) { break; } else { ConsoleIO.BlankLine(); ConsoleIO.GeneralPrompt("An error occurred."); ConsoleIO.GeneralPrompt(stateCheckResponse.Message); ConsoleIO.GeneralPrompt("Press any key to try again..."); continue; } } //Product Type string updatedProductType = ""; while (true) { ConsoleIO.Clear(); ConsoleIO.GeneralPrompt("Available Products"); ConsoleIO.SeperatorBar(); ConsoleIO.BlankLine(); DisplayProductsResponse response = new DisplayProductsResponse(); response = manager.DisplayProductList(); if (response.Success) { ConsoleIO.DisplayListOfProducts(response.Products); } else { ConsoleIO.BlankLine(); ConsoleIO.GeneralPrompt("An error occurred."); ConsoleIO.GeneralPrompt(response.Message); } ConsoleIO.GeneralPrompt("Enter a new product type (Carpet, Laminate, Tile, Wood) OR press enter to continue: "); updatedProductType = Console.ReadLine(); if (string.IsNullOrEmpty(updatedProductType)) { updatedProductType = originalOrderResponse.Order.ProductType; } CheckProductResponse checkProductResponse = new CheckProductResponse(); checkProductResponse = manager.CheckProductTypeEntry(updatedProductType); if (checkProductResponse.Success) { break; } else { ConsoleIO.BlankLine(); ConsoleIO.GeneralPrompt("An error occurred."); ConsoleIO.GeneralPrompt(checkProductResponse.Message); continue; } } //Area decimal updatedAreaSize; while (true) { ConsoleIO.Clear(); ConsoleIO.GeneralPrompt("Enter a new area size OR press enter to continue: "); string updatedAreaSizeString = Console.ReadLine(); if (string.IsNullOrEmpty(updatedAreaSizeString)) { updatedAreaSizeString = originalOrderResponse.Order.Area.ToString(); updatedAreaSize = decimal.Parse(updatedAreaSizeString); break; } else if (decimal.TryParse(updatedAreaSizeString, out updatedAreaSize) && updatedAreaSize > 99) { ConsoleIO.GeneralPrompt("Area size has been changed."); ConsoleIO.BlankLine(); break; } else { ConsoleIO.BlankLine(); ConsoleIO.GeneralPrompt("An error occurred."); continue; } } ConsoleIO.Clear(); ConsoleIO.GeneralPrompt("Updated Order"); ConsoleIO.SeperatorBar(); //Calculate remaining fields for order Order orderToUpdate = manager.CalculateDisplayUpdateOrder(orderDate, orderNumber, updatedCustomerName, updatedStateAB, updatedProductType, updatedAreaSize); //Display order with changes ConsoleIO.DisplaySingleOrder(orderToUpdate); //Confirm change while (true) { ConsoleIO.GeneralPrompt("Please review the edited order above."); bool updateConfirm = ConsoleIO.Confirmation("Are these edits correct? (Enter Y/N): "); if (updateConfirm == true) { //Call Calculate/Update order AND call repo to change manager.UpdateOrder(orderDate, orderNumber, updatedCustomerName, updatedStateAB, updatedProductType, updatedAreaSize); ConsoleIO.GeneralPrompt("Order edit successful."); break; } else { ConsoleIO.GeneralPrompt("Order edit cancelled."); break; } } ConsoleIO.ReadKeyPlusPrompt("Press any key to continue..."); }
/// <summary> /// Executes the tick /// </summary> /// <param name="syncContext">The sync context.</param> private void FastTick(object syncContext) { if (SynchronizationContext.Current == null) { SynchronizationContext.SetSynchronizationContext((SynchronizationContext)syncContext); } try { if (Repository.Static.NextConnectionTime > Repository.Static.Now) { return; } if (Connection.Busy) { return; } Connection.Busy = true; ManagerFactory.Invoke(); if (SlowTickCounter > 5) { SlowTick(); } SlowTickCounter++; if (KeepTickCounter > 28) { KeepAlive(); } KeepTickCounter++; } catch (SocketException ex) { LogService.Warning(string.Format("{0} (IP: {1}, QPort: {2}, Server: {3}/{4}, User: {5}){6}{7}", ex.Message, Repository.Settings.TeamSpeak.Host, Repository.Settings.TeamSpeak.QueryPort, Repository.Settings.TeamSpeak.Instance, Repository.Settings.TeamSpeak.InstancePort, Repository.Settings.TeamSpeak.Username, Environment.NewLine, ex.StackTrace)); Repository.Static.LastConnectionError = Repository.Static.Now; } catch (InvalidOperationException ex) { if (ex.Message.Contains("banned")) { LogService.Warning(ex.Message + ". Please whitelist the Bot!"); } else { LogService.Error(ex); } } catch (Exception ex) { LogService.Error(ex); } finally { Repository.Container.Clean(); Connection.Busy = false; } }
//protected IManager<Clien> ClientDueDateTypesManager { get; set; } private static IManager <ChargeMethodPOCO> GetChargeMethodManager() { return(ManagerFactory.GetInstance().GetManagerFor <ChargeMethodPOCO>()); }
/// <summary> /// Executes the slower tick /// </summary> private void SlowTick() { SlowTickCounter = 0; ManagerFactory.SlowInvoke(); }
private static IManager <ComercialAgentPOCO> GetComercialAgentManager() { return(ManagerFactory.GetInstance().GetManagerFor <ComercialAgentPOCO>()); }
public ConfigurationBase(ILogger startUpLogger) { StartUpLogger = startUpLogger; ManagerFactory = new ManagerFactory(); }
private static IManager <PaymentDueDateTypePOCO> GetPaymentDueDateTypeManager() { return(ManagerFactory.GetInstance().GetManagerFor <PaymentDueDateTypePOCO>()); }
public LoginResponse Post([FromBody] User u) { DispatcherFactory dispatcherFactory = new DispatcherFactory(); DispatcherTable <Dispatcher> instanceDispatcher = (DispatcherTable <Dispatcher>)dispatcherFactory.GetDispatcherInstance(); ManagerFactory managerFactory = new ManagerFactory(); ManagerTable <Manager> instanceManager = (ManagerTable <Manager>)managerFactory.GetManagerInstance(); DriverFactory driverFactory = new DriverFactory(); DriverTable <Driver> instanceDriver = (DriverTable <Driver>)driverFactory.GetDriverInstance(); SessionFactory sessionFactory = new SessionFactory(); SessionsTable <Session> instanceSession = (SessionsTable <Session>)sessionFactory.GetSessionInstance(); var dispatcher = instanceDispatcher.Login(u.email, u.password); var driver = instanceDriver.Login(u.email, u.password); var manager = instanceManager.Login(u.email, u.password); if (dispatcher != null) { var token = GenerateToken().ToString(); Session s = new Session(); s.token = token; s.type = "DISPATCHER"; s.user_id = dispatcher.id; instanceSession.CreateSession(s); LoginResponse lr = new LoginResponse(); lr.token = token; lr.type = "DISPATCHER"; lr.email = dispatcher.email; return(lr); } if (driver != null) { var token = GenerateToken().ToString(); Session s = new Session(); s.token = token; s.type = "DRIVER"; s.user_id = driver.id; instanceSession.CreateSession(s); LoginResponse lr = new LoginResponse(); lr.token = token; lr.type = "DRIVER"; lr.email = driver.email; return(lr); } if (manager != null) { var token = GenerateToken().ToString(); Session s = new Session(); s.token = token; s.type = "MANAGER"; s.user_id = manager.id; instanceSession.CreateSession(s); LoginResponse lr = new LoginResponse(); lr.token = token; lr.type = "MANAGER"; lr.email = manager.email; return(lr); } LoginResponse lr1 = new LoginResponse(); lr1.token = null; lr1.type = "Užívatel neexistuje!"; lr1.email = null; return(lr1); }