public bool InsertOrUpdate(Translate Translate) { if (_epr.Search(c => c.PropertyName == Translate.PropertyName && c.Id != Translate.Id).Any()) { return(_epr.InsertOrUpdate(Translate)); } return(false); }
public bool InsertOrUpdate(DebitNote DebitNote) { var notaDebito = DebitNote; var contratada = _contractorApp.Search(c => c.Id == notaDebito.ContractorId).Include(c => c.DebitNotes).FirstOrDefault(); // Verifico se a nota de débito correponde a empresa selecionada. if (contratada.DebitNotes.Any(c => c.NumberDebitNote == notaDebito.NumberDebitNote)) { return(_epr.InsertOrUpdate(DebitNote)); } var numeroNd = ""; // Pesquiso a última nota de débito do mês recorrente da empresa selecionada. // Cano não exista retorna 000000000, para iniciar a contagem. var oldNd = contratada.DebitNotes.LastOrDefault( c => c.DateRegistration != null && c.DateRegistration.Value.Month == DateTime.Now.Month)? .NumberDebitNote ?? "000000000"; // Pego o cnpj da empresa selecionada var cnpj = new Cnpj(contratada.Cnpj).Codigo; // Faço este loop, pois pode ocorrer situação de o número ser repetido. while (true) { // Pego o último contador e incremento mais 1 (um). var nd = (Convert.ToInt32(oldNd.Remove(0, 6)) + 1).ToString(); // Crio a ND seguindo a regra: CNPJ (apenas dígitos) + ANO + MÊS + Contador. numeroNd = cnpj.Substring(12, 2) + DateTime.Now.Year.ToString().Substring(2, 2) + DateTime.Now.Month.ToString().PadLeft(2, '0') + nd.PadLeft(3, '0'); notaDebito.NumberDebitNote = numeroNd; if (!_epr.Search(c => c.NumberDebitNote == notaDebito.NumberDebitNote).Any()) { break; } oldNd = numeroNd; } return(_epr.InsertOrUpdate(DebitNote)); }
public IQueryable <GroupAccess> Search(Expression <Func <GroupAccess, bool> > expression) { return(_efcmd.Search(expression)); }
public IQueryable <Vehicle> Search(Expression <Func <Vehicle, bool> > expression) { return(_epr.Search(expression)); }
public IQueryable <OsProduct> Search(Expression <Func <OsProduct, bool> > expression) { return(_efcmd.Search(expression)); }
public IQueryable <State> Search(Expression <Func <State, bool> > expression) { return(_efcmd.Search(expression)); }
public IQueryable <OsService> Search(Expression <Func <OsService, bool> > expression) { return(_epr.Search(expression)); }
public IQueryable <Cbo> Search(Expression <Func <Cbo, bool> > expression) { return(_efcmd.Search(expression)); }
public IQueryable <City> Search(Expression <Func <City, bool> > expression) { return(_epr.Search(expression)); }
public IQueryable <PersonAddress> Search(Expression <Func <PersonAddress, bool> > expression) { return(_epr.Search(expression)); }
public IQueryable <ReportForm> Search(Expression <Func <ReportForm, bool> > expression) { return(_epr.Search(expression)); }
public IQueryable <OrderOfService> Search(Expression <Func <OrderOfService, bool> > expression) { return(_efcmd.Search(expression)); }
public IQueryable <OsContractorProduct> Search(Expression <Func <OsContractorProduct, bool> > expression) { return(_epr.Search(expression)); }
public IQueryable <ParkingItemTableOfPrice> Search(Expression <Func <ParkingItemTableOfPrice, bool> > expression) { return(_efcmd.Search(expression)); }
public IQueryable <BillsToReceive> Search(Expression <Func <BillsToReceive, bool> > expression) { return(_efcmd.Search(expression)); }
public IQueryable <FilterCompany> Search(Expression <Func <FilterCompany, bool> > expression) { return(_epr.Search(expression)); }
public IList <OsStock> Search(Expression <Func <OsStock, bool> > condicao) { return(_epr.Search(condicao)); }
public IQueryable <TypeDocumentFinancial> Search(Expression <Func <TypeDocumentFinancial, bool> > expression) { return(_epr.Search(expression)); }
public IQueryable <Taxation> Search(Expression <Func <Taxation, bool> > expression) { return(_epr.Search(expression)); }
public IQueryable <OsDocument> Search(Expression <Func <OsDocument, bool> > expression) { return(_efcmd.Search(expression)); }
public IQueryable <LegalPerson> Search(Expression <Func <LegalPerson, bool> > expression) { return(_efcmd.Search(expression)); }
public IQueryable <Religion> Search(Expression <Func <Religion, bool> > expression) { return(_efcmd.Search(expression)); }
public IQueryable <ChargeLevel> Search(Expression <Func <ChargeLevel, bool> > expression) { return(_epr.Search(expression)); }
public IQueryable <InstallmentOfAccountsReceivable> Search(Expression <Func <InstallmentOfAccountsReceivable, bool> > expression) { return(_efcmd.Search(expression)); }
public IQueryable <ItemInputStock> Search(Expression <Func <ItemInputStock, bool> > expression) { return(_efcmd.Search(expression)); }
public IQueryable <GroupPermission> Search(Expression <Func <GroupPermission, bool> > expression) { return(_epr.Search(expression)); }
public IQueryable <UnitMeasure> Search(Expression <Func <UnitMeasure, bool> > expression) { return(_epr.Search(expression)); }
public IQueryable <SpecialTax> Search(Expression <Func <SpecialTax, bool> > expression) { return(_epr.Search(expression)); }
public IQueryable <UnitMeasureConversion> Search(Expression <Func <UnitMeasureConversion, bool> > expression) { return(_efcmd.Search(expression)); }
public IQueryable <User> Search(Expression <Func <User, bool> > expression) { return(_epr.Search(expression) .Include(c => c.GroupUsers) .Include(c => c.UsersCompanies.Select(d => d.Company))); }