public void InventoryAccessor_GetOrdersByCustomerId_ShouldSucceed() { // Arrange using var inventoryDbContext = InventoryDbContext; try { // Insert seed data into the database using one instance of the context AddCustomers(inventoryDbContext); AddOrders(inventoryDbContext); var inventoryAccessor = new InventoryAccessor(inventoryDbContext, Mapper); // Act var orders = inventoryAccessor.GetOrdersByCustomerId(1); // Assert Assert.True(orders.Any()); Assert.Equal(2, orders.Count); } finally { inventoryDbContext.ChangeTracker .Entries() .ToList() .ForEach(e => e.State = EntityState.Detached); inventoryDbContext.Database.EnsureDeleted(); } }
public void InventoryAccessor_CancelOrder_ForExistingOrder_ShouldSucceed() { // Arrange using var inventoryDbContext = InventoryDbContext; try { const int orderId = 2; // Insert seed data into the database using one instance of the context AddCustomers(inventoryDbContext); AddOrders(inventoryDbContext); var inventoryAccessor = new InventoryAccessor(inventoryDbContext, Mapper); // Act var result = inventoryAccessor.CancelOrder(orderId); // Assert Assert.Equal($"Order {orderId} cancelled.", result); } finally { inventoryDbContext.ChangeTracker .Entries() .ToList() .ForEach(e => e.State = EntityState.Detached); inventoryDbContext.Database.EnsureDeleted(); } }
public Contracts.Order CreateOrder(Contracts.Order order) { var mappedDTOOrder = Mapper.Map <DTOs.Order>(order); var orderAdded = InventoryAccessor.CreateOrder(mappedDTOOrder); return(Mapper.Map <Contracts.Order>(orderAdded)); }
public Contracts.Order UpdateOrder(Contracts.Order order) { var mappedDTOOrder = Mapper.Map <DTOs.Order>(order); var updatedOrder = InventoryAccessor.UpdateOrder(mappedDTOOrder); return(Mapper.Map <Contracts.Order>(updatedOrder)); }
/// <summary> /// Inserts the order and updates the inventory stock within a transaction. /// </summary> /// <param name="order">All information about the order</param> public void InsertOrder(Order order) { using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required)) { OrderAccessor accessor = Accessor; using (DbManager db = accessor.GetDbManager()) { order.Courier = "UPS"; order.Locale = "US_en"; order.ID = accessor.Query.InsertAndGetIdentity(db, order); accessor.InsertStatus(db, order.ID); for (int i = 0; i < order.Lines.Length; i++) { OrderLineItem line = order.Lines[i]; line.OrderID = order.ID; accessor.Query.Insert(line); } } InventoryAccessor inv = InventoryAccessor.CreateInstance(); using (DbManager db = inv.GetDbManager()) foreach (OrderLineItem line in order.Lines) { inv.TakeInventory(db, line.Quantity, line.ItemID); } ts.Complete(); } }
public void InitData(IInventoryStateClient client, InventoryAccessor accessor, ChangeStorage storage) { _storage = storage; _accessor = accessor; LD_Items.Init(client.Items, storage); LD_Gacha.Init(client.Gacha, storage); }
private void _btnOk_Click(object sender, EventArgs e) { _item.Code = _code.Text.Trim(); _item.Description = _description.Text.Trim(); decimal price = 0; if (!decimal.TryParse(_price.Text, out price) || price < 0) { MessageBox.Show("Ошибка в цене", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } _item.Price = price; bool ok = false; using (DbManager db = new DbManager()) if (_newItem) ok = new InventoryAccessor().Insert(db, _item); else ok = new InventoryAccessor().Update(db, _item); if (ok) { DialogResult = DialogResult.OK; Close(); } }
public void InitData(string root, ChangeStorage storage, InventoryAccessor accessor) { _accessor = accessor; _storage = storage; DataId = root; LD_Items?.Init($"{DataId}.storage", storage, _Items); LD_Gacha?.Init($"{DataId}.gacha", storage, _Gacha); }
public static StorageModule CreateClient(ScorersAccessor _scorers, InventoryAccessor _resources) { return(new StorageModule { _scorers = _scorers, _resources = _resources, } ); }
public static EquipmentModule CreateClient(InventoryAccessor _resources, ScorersAccessor _scorers, UnitsAccessor _units, ImpactController _impact, FormulaLogic _formula) { return(new EquipmentModule { _resources = _resources, _scorers = _scorers, _units = _units, _impact = _impact, _formula = _formula, } ); }
public static DropLogic CreateClient(ScorersAccessor _scorers, InventoryAccessor _inventory, UnitsAccessor _units, ExplorerAccessor _explorer, FormulaController _formula, ImpactController _impact) { return(new DropLogic { _scorers = _scorers, _inventory = _inventory, _units = _units, _explorer = _explorer, _formula = _formula, _impact = _impact, } ); }
public List <Equipment> RetrieveEquipmentList() { List <Equipment> equipmentList = null; try { equipmentList = InventoryAccessor.RetrieveEquipment(); } catch (Exception) { throw; } return(equipmentList); }
public List <Item> RetrieveItemList() { List <Item> itemList = null; try { itemList = InventoryAccessor.RetrieveItems(); } catch (Exception) { throw; } return(itemList); }
public int DeleteEquipment(int equipmentID) { int result = 0; try { result = InventoryAccessor.DeleteEquipment(equipmentID); } catch (Exception ex) { throw new ApplicationException("There was a problem connecting to the server.", ex); } return(result); }
public int CreateEquipment(string name, string description, int defense) { int result = 0; try { result = InventoryAccessor.AddEquipment(name, description, defense); } catch (Exception ex) { throw new ApplicationException("There was a problem connecting to the server.", ex); } return(result); }
public int CreateItem(string name, string description, float attackBoost, float defenseBoost) { int result = 0; try { result = InventoryAccessor.AddItem(name, description, attackBoost, defenseBoost); } catch (Exception ex) { throw new ApplicationException("There was a problem connecting to the server.", ex); } return(result); }
public List <Weapon> RetrieveWeaponList() { List <Weapon> weaponList = null; try { weaponList = InventoryAccessor.RetrieveWeapons(); } catch (Exception) { throw; } return(weaponList); }
public int CreateWeapon(string name, string description, int attack) { int result = 0; try { result = InventoryAccessor.AddWeapon(name, description, attack); } catch (Exception ex) { throw new ApplicationException("There was a problem connecting to the server.", ex); } return(result); }
public int UpdateWeapon(int weaponID, string oldName, string newName, string oldDescription, string newDescription, int oldAttack, int newAttack) { int result = 0; try { result = InventoryAccessor.UpdateWeapon(weaponID, oldName, newName, oldDescription, newDescription, oldAttack, newAttack); } catch (Exception ex) { throw new ApplicationException("There was a problem connecting to the server.", ex); } return(result); }
public int UpdateItem(int itemID, string oldName, string newName, string oldDescription, string newDescription, float oldAttackBoost, float newAttackBoost, float oldDefenseBoost, float newDefenseBoost) { int result = 0; try { result = InventoryAccessor.UpdateItem(itemID, oldName, newName, oldDescription, newDescription, oldAttackBoost, newAttackBoost, oldDefenseBoost, newDefenseBoost); } catch (Exception ex) { throw new ApplicationException("There was a problem connecting to the server.", ex); } return(result); }
public int UpdateEquipment(int equipmentID, string oldName, string newName, string oldDescription, string newDescription, int oldDefense, int newDefense) { int result = 0; try { result = InventoryAccessor.UpdateEquipment(equipmentID, oldName, newName, oldDescription, newDescription, oldDefense, newDefense); } catch (Exception ex) { throw new ApplicationException("There was a problem connecting to the server.", ex); } return(result); }
public InternalAccessors(LogicData LogicData, IStateFactory factory) { Factory = factory; ConditionController = new ConditionController(); FormulaController = new FormulaController(); AchievementAccessor = new AchievementAccessor(); BattleAccessor = new BattleAccessor(); CutSceneAccessor = new CutSceneAccessor(); ExplorerAccessor = new ExplorerAccessor(); InventoryAccessor = new InventoryAccessor(); LogAccessor = new LogAccessor(); LogAccessor.Data = LogicData; PlayerAccessor = new PlayerAccessor(); ScorersAccessor = new ScorersAccessor(); SettingsAccessor = new SettingsAccessor(); ShopAccessor = new ShopAccessor(); UnitsAccessor = new UnitsAccessor(); }
public static ConditionLogic CreateClient(InventoryAccessor _inventoryAccessor, ScorersAccessor _scorersAccessor, PlayerAccessor _profileAccessor, UnitsAccessor _unitAccessor, BattleAccessor _battleAccessor, ExplorerAccessor _explorerAccessor, SettingsAccessor _settingsAccessor, AchievementAccessor _achievementAccessor, FormulaLogic _formulaLogic, ContextLogic _contextLogic, ScorersLogic _scorerLogic, LogicData _data, ConditionController _controller) { return(new ConditionLogic { _inventoryAccessor = _inventoryAccessor, _scorersAccessor = _scorersAccessor, _profileAccessor = _profileAccessor, _unitAccessor = _unitAccessor, _battleAccessor = _battleAccessor, _explorerAccessor = _explorerAccessor, _settingsAccessor = _settingsAccessor, _achievementAccessor = _achievementAccessor, _formulaLogic = _formulaLogic, _contextLogic = _contextLogic, _scorerLogic = _scorerLogic, _data = _data, _controller = _controller, } ); }
public void InventoryAccessor_UpdateOrder_ForExistingOrder_ShouldSucceed() { // Arrange using var inventoryDbContext = InventoryDbContext; try { // Insert seed data into the database using one instance of the context AddCustomers(inventoryDbContext); AddOrders(inventoryDbContext); var order = new DTOs.Order { Id = 1, Name = "Hashbrowns", DateCreated = DateTime.Now, DateLastModified = DateTime.Now, CustomerId = 1 }; var inventoryAccessor = new InventoryAccessor(inventoryDbContext, Mapper); // Act var orderUpdated = inventoryAccessor.UpdateOrder(order); // Assert Assert.NotNull(orderUpdated); Assert.Equal(order.Name, orderUpdated.Name); } finally { inventoryDbContext.ChangeTracker .Entries() .ToList() .ForEach(e => e.State = EntityState.Detached); inventoryDbContext.Database.EnsureDeleted(); } }
public void InventoryAccessor_CancelOrder_ForNotExistingOrder_ShouldReturnNull() { // Arrange using var inventoryDbContext = InventoryDbContext; try { var inventoryAccessor = new InventoryAccessor(inventoryDbContext, Mapper); // Act var result = inventoryAccessor.CancelOrder(99); // Assert Assert.Null(result); } finally { inventoryDbContext.ChangeTracker .Entries() .ToList() .ForEach(e => e.State = EntityState.Detached); inventoryDbContext.Database.EnsureDeleted(); } }
public static GachaModule CreateClient(ImpactController _impactLogic, ScorersAccessor _scorers, InventoryAccessor _resources, UnitsAccessor _units, ExplorerAccessor _explorer, DropLogic _dropLogic, ConditionController _condition, FormulaLogic _formuls) { return(new GachaModule { _impactLogic = _impactLogic, _scorers = _scorers, _resources = _resources, _units = _units, _explorer = _explorer, _dropLogic = _dropLogic, _condition = _condition, _formuls = _formuls, } ); }
public static ExplorerProgressModule CreateClient(ExplorerAccessor _explorer, InventoryAccessor _inventory, UnitsAccessor _units, SettingsAccessor _settings, ScorersAccessor _scorers, BattleAccessor _battle, ExplorerLogic _explorerLogic, FormulaLogic _formula, ImpactController _impactLogic) { return(new ExplorerProgressModule { _explorer = _explorer, _inventory = _inventory, _units = _units, _settings = _settings, _scorers = _scorers, _battle = _battle, _explorerLogic = _explorerLogic, _formula = _formula, _impactLogic = _impactLogic, } ); }
public ConditionIntentoryChecker(FormulaLogic logic, InventoryAccessor inventory) { _inventory = inventory; _logic = logic; }
public ImpactItemDataExecutor(FormulaLogic logic, InventoryAccessor inventory, ExplorerAccessor explorer) { _inventory = inventory; _explorer = explorer; _logic = logic; }
public string CancelOrder(int OrderId) { return(InventoryAccessor.CancelOrder(OrderId)); }
public List <Contracts.Order> GetOrdersByCustomerId(int customerId) { var orders = InventoryAccessor.GetOrdersByCustomerId(customerId); return(Mapper.Map <List <Contracts.Order> >(orders)); }