public Guid Add(AccountTransaction accountTransaction)
        {
                    
            ValidationResultInfo vri = Validate(accountTransaction);
            if (!vri.IsValid)
            {
                throw new DomainValidationException(vri, "Failed To Validate AccountTransaction");
            }
            tblAccountTransaction tblAccTr  =_ctx.tblAccountTransaction.FirstOrDefault(n => n.Id == accountTransaction.Id);
            DateTime dt = DateTime.Now;
            if (tblAccTr == null)
            {
                tblAccTr = new tblAccountTransaction();
                tblAccTr.Id = accountTransaction.Id;
                _ctx.tblAccountTransaction.AddObject(tblAccTr);
                _log.DebugFormat("accountTransaction.Id == 0");
            }
           


            tblAccTr.AccountId = accountTransaction.Account.Id;
            tblAccTr.Amount = accountTransaction.Amount;
            tblAccTr.DocumentType = (int)accountTransaction.DocumentType;
            tblAccTr.DocumentId = accountTransaction.DocumentId;
            tblAccTr.DateInserted = accountTransaction.DateInserted;
            
            _log.DebugFormat("Saving/Updating AccountTransaction");

           _ctx.SaveChanges();
            return tblAccTr.Id;
        }
 private void AssertAccountTransaction(AccountTransaction accountTraX, AccountTransaction accountTraY)
 {
     Assert.AreEqual(accountTraX.Account.Balance, accountTraY.Account.Balance);
     Assert.AreEqual(accountTraX.Amount, accountTraY.Amount);
     Assert.AreEqual(accountTraX.DocumentType, accountTraY.DocumentType);
     Assert.AreEqual(accountTraX.Id, accountTraY.Id);
 }
 public AccountTransaction Map(tblAccountTransaction tblAccTr){
 
     AccountTransaction accTr = new AccountTransaction(tblAccTr.Id){
     
         Account  = _accountRepository.GetById(tblAccTr.AccountId),
         Amount = (decimal)tblAccTr.Amount,
         DocumentType = (DocumentType)tblAccTr.DocumentType,
         DocumentId = tblAccTr.DocumentId,
         DateInserted = tblAccTr.DateInserted
     };
 
   
     return accTr;
 
 }
 public ValidationResultInfo Validate(AccountTransaction itemToValidate)
 {
     ValidationResultInfo vri = itemToValidate.BasicValidation();
     if (itemToValidate.Id == Guid.Empty)
         vri.Results.Add(new ValidationResult("Enter Valid  Guid ID"));
     return vri;
 }