private string toJson(CfopToUsageMap map) { string result = string.Empty; dynamic record = new ExpandoObject(); record.Code = map.RecId; record.Name = map.RecId; record.U_CFOP = map.Cfop; record.U_LGCYUSAGE = map.UsageLegacy; record.U_USAGE = map.Usage; record.U_TAXCODE = map.TaxCode; record.U_DOCTYPE = map.DocumentType; record.U_SERVICEITEM = map.ServiceItem; record.U_WAREHOUSE = map.Warehouse; record.U_CONTAPN = map.ContaPN; record.U_CONTADEBITO = map.ContaDebito; record.U_CONTACREDITO = map.ContaCredito; record.U_CONTACONTROLE = map.ContaControle; record.U_CONTATAXA = map.ContaTaxa; record.U_OBSERVACOES = map.Observacoes; result = JsonConvert.SerializeObject(record); return(result); }
public void CT1_Insert() { Assert.That(async() => await _service.Insert(_map), Throws.Nothing); Task.Delay(2000); CfopToUsageMap map = readMap(); Assert.IsNotNull(map); }
public void CT3_Delete() { CfopToUsageMap map = readMap(); Assert.That(async() => await _service.Delete(map), Throws.Nothing); map = readMap(); Assert.IsNull(map); }
async public Task Delete(CfopToUsageMap entity) { ServiceLayerResponse response = await _serviceLayerConnector.Delete($"{SL_TABLE_NAME}('{entity.RecId}')", ""); if (!response.success) { string message = $"Erro ao excluir registro de '{entity.EntityName}': {response.errorCode}-{response.errorMessage}"; Console.WriteLine(message); throw new ApplicationException(message); } }
async public Task Insert(CfopToUsageMap entity) { string record = toJson(entity); ServiceLayerResponse response = await _serviceLayerConnector.Post(SL_TABLE_NAME, record); if (!response.success) { string message = $"Erro ao enviar registro de '{entity.EntityName}': {response.errorCode}-{response.errorMessage}"; Console.WriteLine(message); throw new ApplicationException(message); } }
async public Task Update(CfopToUsageMap entity) { string record = toJson(entity); ServiceLayerResponse response = await _serviceLayerConnector.Put($"{SL_TABLE_NAME}('{entity.RecId}')", record); if (!response.success) { string message = $"Erro ao atualizar registro de '{entity.EntityName}': {response.errorCode}-{response.errorMessage}"; Console.WriteLine(message); throw new ApplicationException(message); } }
public void CT2_Update() { CfopToUsageMap map = readMap(); map.Usage = 11; Assert.That(async() => await _service.Update(map), Throws.Nothing); CfopToUsageMap newMap = readMap(); Assert.IsNotNull(newMap); Assert.AreEqual(map.Usage, newMap.Usage); }
async public Task <CfopToUsageMap> Find(List <Criteria> criterias) { string recid = criterias[0].Value; string query = Global.BuildQuery($"{SL_TABLE_NAME}('{recid}')"); string data = await _serviceLayerConnector.getQueryResult(query); ExpandoObject record = Global.parseQueryToObject(data); CfopToUsageMap result = null; if (record != null) { result = toRecord(record); } return(result); }
private CfopToUsageMap toRecord(dynamic record) { CfopToUsageMap map = new CfopToUsageMap(); map.RecId = Guid.Parse(record.Code); map.Cfop = Convert.ToInt64(record.U_CFOP); map.UsageLegacy = record.U_LGCYUSAGE; map.Usage = Convert.ToInt64(record.U_USAGE); map.TaxCode = record.U_TAXCODE; map.DocumentType = (CfopToUsageMap.DocumentTypeEnum)Convert.ToInt64(record.U_DOCTYPE); map.ServiceItem = record.U_SERVICEITEM; map.Warehouse = Convert.ToInt64(record.U_WAREHOUSE); map.ContaPN = record.U_CONTAPN; map.ContaDebito = record.U_CONTADEBITO; map.ContaCredito = record.U_CONTACREDITO; map.ContaControle = record.U_CONTACONTROLE; map.ContaTaxa = record.U_CONTATAXA; map.Observacoes = record.U_OBSERVACOES; return(map); }
public void Setup() { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.AddJsonFile(".\\appSettingsB1.json"); ILoggerFactory factory = new LoggerFactory(); ILogger <Service> logger = factory.CreateLogger <Service>(); _configuration = builder.Build(); _service = new Service(_configuration, logger); doLogin(); _map = new CfopToUsageMap() { Cfop = 1102, UsageLegacy = "001", DocumentType = CfopToUsageMap.DocumentTypeEnum.PurchInvoice, Usage = 10, TaxCode = "1102001", ServiceItem = "1001" }; }