public TaxProfileType FindTaxProfileById(int Id) { TaxProfileType item = null; using (var context = new AgileInvoiceDbContext(_connectionString)) { IQueryable <TaxProfile> lista = from row in context.TaxProfiles where row.IdTaxProfile == Id select row; if (lista.Count() > 0) { TaxProfile entitie = lista.FirstOrDefault(); item = new TaxProfileType(); item.IdTaxProfile = entitie.IdTaxProfile; item.Name = entitie.Name; item.Identification = entitie.Identification; item.Street = entitie.Street; item.ExteriorNumber = entitie.ExteriorNumber; item.InteriorNumber = entitie.InteriorNumber; item.Suburb = entitie.Suburb; item.Municipality = entitie.Municipality; item.State = entitie.State; item.Country = entitie.Country; item.PostCode = entitie.PostCode; } } return(item); }
public int AddTaxProfile(TaxProfileType item) { int result = 0; using (var context = new AgileInvoiceDbContext(_connectionString)) { TaxProfile entitie = new TaxProfile(); entitie.Name = item.Name; entitie.Identification = item.Identification; entitie.Street = item.Street; entitie.ExteriorNumber = item.ExteriorNumber; entitie.InteriorNumber = item.InteriorNumber; entitie.Suburb = item.Suburb; entitie.Municipality = item.Municipality; entitie.State = item.State; entitie.Country = item.Country; entitie.PostCode = item.PostCode; entitie.CreationDate = DateTime.Now; context.TaxProfiles.Add(entitie); result = context.SaveChanges(); } return(result); }