public void CompanyCurrencyUpdateTestUsingoAuth(ServiceContext qboContextoAuth) { QueryService <CompanyCurrency> entityQuery = new QueryService <CompanyCurrency>(qboContextoAuth); List <CompanyCurrency> foundall = entityQuery.ExecuteIdsQuery("SELECT * FROM CompanyCurrency").ToList <CompanyCurrency>(); foreach (CompanyCurrency found in foundall) { CompanyCurrency changed = QBOHelper.UpdateCompanyCurrency(qboContextoAuth, found); //Update the returned entity data CompanyCurrency updated = Helper.Update <CompanyCurrency>(qboContextoAuth, changed);//Verify the updated CompanyCurrency } }
public void CompanyCurrencyUpdatedAsyncTestsUsingoAuth() { //Creating the CompanyCurrency for Adding CompanyCurrency entity = QBOHelper.CreateCompanyCurrency(qboContextoAuth); //Adding the CompanyCurrency CompanyCurrency added = Helper.Add <CompanyCurrency>(qboContextoAuth, entity); //Update the CompanyCurrency CompanyCurrency updated = QBOHelper.UpdateCompanyCurrency(qboContextoAuth, added); //Call the service CompanyCurrency updatedReturned = Helper.UpdateAsync <CompanyCurrency>(qboContextoAuth, updated); //Verify updated CompanyCurrency QBOHelper.VerifyCompanyCurrency(updated, updatedReturned); }
public void CompanyCurrencyVoidTestUsingoAuth() { //Creating the entity for Adding CompanyCurrency entity = QBOHelper.CreateCompanyCurrency(qboContextoAuth); //Adding the entity CompanyCurrency added = Helper.Add <CompanyCurrency>(qboContextoAuth, entity); //Void the returned entity try { CompanyCurrency voided = Helper.Void <CompanyCurrency>(qboContextoAuth, added); Assert.AreEqual(EntityStatusEnum.Voided, voided.status); } catch (IdsException ex) { Assert.Fail(); } }
[Ignore] //Soft delete public void CompanyCurrencyDeleteTestUsingoAuth() { //Creating the CompanyCurrency for Adding CompanyCurrency companyCurrency = QBOHelper.CreateCompanyCurrency(qboContextoAuth); //Adding the CompanyCurrency CompanyCurrency added = Helper.Add <CompanyCurrency>(qboContextoAuth, companyCurrency); //Delete the returned entity try { CompanyCurrency deleted = Helper.Delete <CompanyCurrency>(qboContextoAuth, added); Assert.AreEqual(EntityStatusEnum.Deleted, deleted.status); } catch (IdsException ex) { Assert.Fail(); } }
public Response addCompanyCurrency(CompanyCurrency companyCurrency) { string sql = "insert into tblCompanyCurrency (exchange,active,dateRegister,idCompany,idCurrencyMain,idCurrencyAltern,idUser) values (@exchange,@active,@dateRegister,@idCompany,@idCurrencyMain,@idCurrencyAltern,@idUser)"; companyCurrency.dateRegister = DateTime.Now; string sqlGetActive = "select idCompanyCurrency from tblCompanyCurrency where active=1 and idCompany=" + companyCurrency.idCompany; using (var sqlConnection = new SqlConnection(conexion)) { var queryGetCurrencyMain = "select top 1 idCurrencyMain from tblCompanyCurrency where idCompany=" + companyCurrency.idCompany; var idCurrencyMain = sqlConnection.ExecuteScalar <int>(queryGetCurrencyMain, commandType: System.Data.CommandType.Text); companyCurrency.idCurrencyMain = idCurrencyMain; var idCompanyActive = sqlConnection.ExecuteScalar <int>(sqlGetActive, commandType: System.Data.CommandType.Text); string sqlUpdateActive = "update tblCompanyCurrency set active=0 where idCompanyCurrency =" + idCompanyActive; var res = sqlConnection.Execute(sqlUpdateActive, new { idCompanyActive = idCompanyActive }); try { var respuesta = sqlConnection.Execute(sql, companyCurrency); return(new Response { Done = true, Message = "Moneda insertada Exitosamente", Value = -1 }); } catch (SqlException e) { //error 42000 o 3726 if (e.ErrorCode == -2146232060) { return(new Response { Done = false, Message = "Registro repetido" }); } else { return(new Response { Done = false, Message = e.Message, Value = 0 }); } } } }
public void CompanyCurrencyBatchUsingoAuth() { Dictionary <OperationEnum, object> batchEntries = new Dictionary <OperationEnum, object>(); CompanyCurrency existing = Helper.FindOrAdd(qboContextoAuth, new CompanyCurrency()); batchEntries.Add(OperationEnum.create, QBOHelper.CreateCompanyCurrency(qboContextoAuth)); batchEntries.Add(OperationEnum.update, QBOHelper.UpdateCompanyCurrency(qboContextoAuth, existing)); batchEntries.Add(OperationEnum.query, "select * from CompanyCurrency"); //batchEntries.Add(OperationEnum.delete, existing); ReadOnlyCollection <IntuitBatchResponse> batchResponses = Helper.BatchTest <CompanyCurrency>(qboContextoAuth, batchEntries); int position = 0; foreach (IntuitBatchResponse resp in batchResponses) { if (resp.ResponseType == ResponseType.Exception) { Assert.Fail(resp.Exception.ToString()); } if (resp.ResponseType == ResponseType.Entity) { Assert.IsFalse(string.IsNullOrEmpty((resp.Entity as CompanyCurrency).Id)); } else if (resp.ResponseType == ResponseType.Query) { Assert.IsTrue(resp.Entities != null && resp.Entities.Count > 0); } else if (resp.ResponseType == ResponseType.CdcQuery) { Assert.IsTrue(resp.CDCResponse != null && resp.CDCResponse.entities != null && resp.CDCResponse.entities.Count > 0); } position++; } }
public Company insertCompany(Company company) { string sql = "insert into tblCompanies (nameCompany,nit,sigla,cellphone,email,addressCompany,levels,idUser)" + " values (@nameCompany,@nit,@sigla,@cellphone,@email,@addressCompany,@levels,@idUser) SELECT SCOPE_IDENTITY()"; using (var connection = new SqlConnection(conexion)) { connection.Open(); using (var transaction = connection.BeginTransaction()) { try { var respuesta = connection.ExecuteScalar(sql, company, transaction: transaction); int idCompany = Convert.ToInt32(respuesta); string codeAccountInsert = string.Concat(Enumerable.Repeat(".0", company.levels - 1)); string codeAccountInsertSecond = string.Concat(Enumerable.Repeat(".0", company.levels - 2)); string sqlInsertAccount1 = "insert into tblAccounts (codeAccount,nameAccount,levelAccount,typeAccount,idUser,idCompany,idAccountFather) values ('1" + codeAccountInsert + "','Activo',1,1,1," + idCompany + ",null)"; string sqlInsertAccount2 = "insert into tblAccounts (codeAccount,nameAccount,levelAccount,typeAccount,idUser,idCompany,idAccountFather) values ('2" + codeAccountInsert + "','Pasivo',1,1,1," + idCompany + ",null)"; string sqlInsertAccount3 = "insert into tblAccounts (codeAccount,nameAccount,levelAccount,typeAccount,idUser,idCompany,idAccountFather) values ('3" + codeAccountInsert + "','Patrimonio',1,1,1," + idCompany + ",null)"; string sqlInsertAccount4 = "insert into tblAccounts (codeAccount,nameAccount,levelAccount,typeAccount,idUser,idCompany,idAccountFather) values ('4" + codeAccountInsert + "','Ingresos',1,1,1," + idCompany + ",null)"; string sqlInsertAccount5 = "insert into tblAccounts (codeAccount,nameAccount,levelAccount,typeAccount,idUser,idCompany,idAccountFather) values (@codeAccount,@nameAccount,@levelAccount,@typeAccount,@idUser,@idCompany,null) SELECT SCOPE_IDENTITY()"; connection.Execute(sqlInsertAccount1, transaction: transaction); connection.Execute(sqlInsertAccount2, transaction: transaction); connection.Execute(sqlInsertAccount3, transaction: transaction); connection.Execute(sqlInsertAccount4, transaction: transaction); var account1 = new Account(); account1.codeAccount = "5" + codeAccountInsert; account1.nameAccount = "Egresos"; account1.levelAccount = 1; account1.typeAccount = 1; account1.idUser = 1; account1.idCompany = idCompany; var egresos = connection.ExecuteScalar(sqlInsertAccount5, account1, transaction: transaction); int idEgresos = Convert.ToInt32(egresos); string sqlInsertAccount51 = "insert into tblAccounts (codeAccount,nameAccount,levelAccount,typeAccount,idUser,idCompany,idAccountFather) values ('5.1" + codeAccountInsertSecond + "','Costos',2,1,1," + idCompany + "," + idEgresos + ")"; string sqlInsertAccount52 = "insert into tblAccounts (codeAccount,nameAccount,levelAccount,typeAccount,idUser,idCompany,idAccountFather) values ('5.2" + codeAccountInsertSecond + "','Gastos',2,1,1," + idCompany + "," + idEgresos + ")"; connection.Execute(sqlInsertAccount51, transaction: transaction); connection.Execute(sqlInsertAccount52, transaction: transaction); company.idCompany = idCompany; string sqlInsertCurrencyCompany = "insert into tblCompanyCurrency (exchange,active,dateRegister,idCompany,idCurrencyMain,idCurrencyAltern,idUser) values (@exchange,@active,@dateRegister,@idCompany,@idCurrencyMain,1,@idUser)"; var currencyCompany = new CompanyCurrency(); currencyCompany.active = true; currencyCompany.exchange = 0; currencyCompany.idCompany = idCompany; currencyCompany.dateRegister = DateTime.Now; currencyCompany.idCurrencyMain = company.idCurrency; currencyCompany.idCurrencyAltern = 1; currencyCompany.idUser = 1; connection.Execute(sqlInsertCurrencyCompany, currencyCompany, transaction: transaction); transaction.Commit(); return(company); } catch (SqlException e) { transaction.Rollback(); if (e.ErrorCode == -2146232060) { return(new Company()); //return new Response //{ // Done = false, // Message = "Registro repetido" //}; } else { return(new Company()); //return new Response { Done = false, Message = e.Message,Value=0 }; } } } } }
public Response addCompanyCurrency(CompanyCurrency companyCurrency) { return(classCompanyCurrency.addCompanyCurrency(companyCurrency)); }
public CompanyCurrency insertAccount(CompanyCurrency companyCurrency) { return(classCompanyCurrency.insertCompanyCurrency(companyCurrency)); }