public bool AddTransactionType(TransactionType model)
 {
     var check = _db.Get<TransactionType>().FirstOrDefault(x => x.Name == model.Name && x.Code == model.Code);
        if (check != null)
        {
        throw new Exception("This TransactionType already Exist");
        }
        else
        {
        return _db.Add(new TransactionType
        {
            Code = model.Code,
            Name = model.Name,
            Description = model.Description
        });
        }
 }
 public bool Edit(TransactionType model)
 {
     bool result = false;
        try
        {
        var transx = _db.Get<TransactionType>().FirstOrDefault(x =>x.Id==model.Id);
        if (transx != null)
        {
            transx.Code = model.Code;
            transx.Description = model.Description;
            transx.Name = model.Name;
           result =_db.Update(transx);
            _db.Commit();
        }
        return result;
        }
        catch (Exception ex)
        {
        _db.Rollback();
        throw ex;
        }
 }
 public TransactionType GetByName(string name)
 {
     var trnx = new TransactionType();
      if(string.IsNullOrEmpty(name))
      {
      return trnx;
      }
      else
      {
        trnx = _db.Get<TransactionType>().FirstOrDefault(x=>x.Name==name);
        return trnx;
      }
 }
        private Fee GetFeeIfTransactionIsAllowed(TransactionType transactionType, Channel channel, Scheme scheme)
        {
            try
               {
               foreach (var item in scheme.TransactionTypeChannelFees)
               {
                   if (channel != null)
                   {
                       if (item.TransactionType.Code == transactionType.Code && item.Channel.Code == channel.Code)
                       {
                           return item.Fee;
                       }
                   }
               }

               return null;
               }
               catch (Exception ex)
               {
               Logger.Log("Error: while checking if transaction is allowed \n" + ex.Message);
               return null;
               }
        }