protected override void SetIdForForeignKeys <TObject, TModelForSet>(TModelForSet modelsForSet, IUnitOfWork unitOfWork, ref TObject operationParam) { debt_DebtOperations operation = operationParam as debt_DebtOperations; DebtForeignKeyForSetModels fKModel = modelsForSet as DebtForeignKeyForSetModels; if (operation != null && fKModel != null) { if (fKModel.AgentModel != null) { operation.AgentId = fKModel.AgentModel.Id; } operation.UserId = Convert.ToInt32(fKModel.UserId); operation.DebtTypeId = Convert.ToInt32(fKModel.DebtType); } }
public override bool addNewOperation <TObject>(TObject modelParam, string userName) { AddDebtModel model = modelParam as AddDebtModel; if (model != null && model != null && ValidationManager.modelIsValid(model)) { DebtTypeEnum operationType = model.DebtType; ModelsForDebtOperationModel modelForOperation = new ModelsForDebtOperationModel { AgentModel = new NameIdClassModel() }; GetModelsForOperationOptions(ref model, modelForOperation); debt_DebtOperations newOperation = new debt_DebtOperations() { StartDate = model.StartDate, EndDate = model.EndDate, StartSum = model.StartSum, RewardSum = model.RewardSum, Comment = model.Commentary, CurrencyId = model.CurrencyId, IsInProgress = true }; DebtForeignKeyForSetModels fKModel = new DebtForeignKeyForSetModels { AgentModel = modelForOperation.AgentModel, UserId = userName, DebtType = operationType }; SetIdForForeignKeys(fKModel, DIManager.UnitOfWork, ref newOperation); return(AddOperationToDB(newOperation)); } return(false); }