public SystemResponse<string> CreatePersonalProtectiveEquipmentTransaction(PersonalProtectiveEquipmentTransaction personalProtectiveEquipmentTransaction) { var transactionType = GetTransactionType(personalProtectiveEquipmentTransaction.TransactionTypeId); var currentModelInventory = GetPersonalProtectiveEquipmentCategoryTypeModelInventory(personalProtectiveEquipmentTransaction.PersonalProtectiveEquipmentCategoryTypeModelId); SystemResponse<string> response = new SystemResponse<string>("No Error"); //if its an outgoing transaction check the inventory levels //if the amount in current inventory exceeds an error must be returned //if transaction is outgoing check inventory levels first //check the direction of the transaction if (transactionType.TransactionDirection.Name == "Outgoing") { //make sure inventory being issued doesnt exceed existing quantity if (currentModelInventory.Quantity < personalProtectiveEquipmentTransaction.Quantity) { response.ErrorMessages.Add("There aren't enough items in the inventory to meet that quantity."); response.ErrorOccurred = true; } else { currentModelInventory.Quantity -= personalProtectiveEquipmentTransaction.Quantity; currentModelInventory.PersonalProtectiveEquipmentCategoryTypeModel = null; UpdatePersonalProtectiveEquipmentCategoryTypeModelInventory(currentModelInventory); _dataManager.CreatePersonalProtectiveEquipmentTransaction(personalProtectiveEquipmentTransaction); } } else if (transactionType.TransactionDirection.Name == "Incoming") { currentModelInventory.Quantity += personalProtectiveEquipmentTransaction.Quantity; currentModelInventory.PersonalProtectiveEquipmentCategoryTypeModel = null; UpdatePersonalProtectiveEquipmentCategoryTypeModelInventory(currentModelInventory); _dataManager.CreatePersonalProtectiveEquipmentTransaction(personalProtectiveEquipmentTransaction); } else //neutral transaction { _dataManager.CreatePersonalProtectiveEquipmentTransaction(personalProtectiveEquipmentTransaction); } return response; //may need to return error here indicating that the transaction cannot go through }
public void UpdatePersonalProtectiveEquipmentTransaction(PersonalProtectiveEquipmentTransaction personalProtectiveEquipmentTransaction) { _dataManager.UpdatePersonalProtectiveEquipmentTransaction(personalProtectiveEquipmentTransaction); }
public void CreatePersonalProtectiveEquipmentTransaction(PersonalProtectiveEquipmentTransaction personalProtectiveEquipmentTransaction) { var repository = new PersonalProtectiveEquipmentTransactionRepository(_db); repository.Add(personalProtectiveEquipmentTransaction); repository.Save(); }