Esempio n. 1
0
 public bool InsertOrUpdate(Translate Translate)
 {
     if (_epr.Search(c => c.PropertyName == Translate.PropertyName && c.Id != Translate.Id).Any())
     {
         return(_epr.InsertOrUpdate(Translate));
     }
     return(false);
 }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
 public IQueryable <GroupAccess> Search(Expression <Func <GroupAccess, bool> > expression)
 {
     return(_efcmd.Search(expression));
 }
Esempio n. 4
0
 public IQueryable <Vehicle> Search(Expression <Func <Vehicle, bool> > expression)
 {
     return(_epr.Search(expression));
 }
Esempio n. 5
0
 public IQueryable <OsProduct> Search(Expression <Func <OsProduct, bool> > expression)
 {
     return(_efcmd.Search(expression));
 }
Esempio n. 6
0
 public IQueryable <State> Search(Expression <Func <State, bool> > expression)
 {
     return(_efcmd.Search(expression));
 }
Esempio n. 7
0
 public IQueryable <OsService> Search(Expression <Func <OsService, bool> > expression)
 {
     return(_epr.Search(expression));
 }
Esempio n. 8
0
 public IQueryable <Cbo> Search(Expression <Func <Cbo, bool> > expression)
 {
     return(_efcmd.Search(expression));
 }
Esempio n. 9
0
 public IQueryable <City> Search(Expression <Func <City, bool> > expression)
 {
     return(_epr.Search(expression));
 }
Esempio n. 10
0
 public IQueryable <PersonAddress> Search(Expression <Func <PersonAddress, bool> > expression)
 {
     return(_epr.Search(expression));
 }
Esempio n. 11
0
 public IQueryable <ReportForm> Search(Expression <Func <ReportForm, bool> > expression)
 {
     return(_epr.Search(expression));
 }
Esempio n. 12
0
 public IQueryable <OrderOfService> Search(Expression <Func <OrderOfService, bool> > expression)
 {
     return(_efcmd.Search(expression));
 }
Esempio n. 13
0
 public IQueryable <OsContractorProduct> Search(Expression <Func <OsContractorProduct, bool> > expression)
 {
     return(_epr.Search(expression));
 }
Esempio n. 14
0
 public IQueryable <ParkingItemTableOfPrice> Search(Expression <Func <ParkingItemTableOfPrice, bool> > expression)
 {
     return(_efcmd.Search(expression));
 }
Esempio n. 15
0
 public IQueryable <BillsToReceive> Search(Expression <Func <BillsToReceive, bool> > expression)
 {
     return(_efcmd.Search(expression));
 }
Esempio n. 16
0
 public IQueryable <FilterCompany> Search(Expression <Func <FilterCompany, bool> > expression)
 {
     return(_epr.Search(expression));
 }
Esempio n. 17
0
 public IList <OsStock> Search(Expression <Func <OsStock, bool> > condicao)
 {
     return(_epr.Search(condicao));
 }
Esempio n. 18
0
 public IQueryable <TypeDocumentFinancial> Search(Expression <Func <TypeDocumentFinancial, bool> > expression)
 {
     return(_epr.Search(expression));
 }
Esempio n. 19
0
 public IQueryable <Taxation> Search(Expression <Func <Taxation, bool> > expression)
 {
     return(_epr.Search(expression));
 }
Esempio n. 20
0
 public IQueryable <OsDocument> Search(Expression <Func <OsDocument, bool> > expression)
 {
     return(_efcmd.Search(expression));
 }
Esempio n. 21
0
 public IQueryable <LegalPerson> Search(Expression <Func <LegalPerson, bool> > expression)
 {
     return(_efcmd.Search(expression));
 }
Esempio n. 22
0
 public IQueryable <Religion> Search(Expression <Func <Religion, bool> > expression)
 {
     return(_efcmd.Search(expression));
 }
Esempio n. 23
0
 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));
 }
Esempio n. 25
0
 public IQueryable <ItemInputStock> Search(Expression <Func <ItemInputStock, bool> > expression)
 {
     return(_efcmd.Search(expression));
 }
Esempio n. 26
0
 public IQueryable <GroupPermission> Search(Expression <Func <GroupPermission, bool> > expression)
 {
     return(_epr.Search(expression));
 }
Esempio n. 27
0
 public IQueryable <UnitMeasure> Search(Expression <Func <UnitMeasure, bool> > expression)
 {
     return(_epr.Search(expression));
 }
Esempio n. 28
0
 public IQueryable <SpecialTax> Search(Expression <Func <SpecialTax, bool> > expression)
 {
     return(_epr.Search(expression));
 }
Esempio n. 29
0
 public IQueryable <UnitMeasureConversion> Search(Expression <Func <UnitMeasureConversion, bool> > expression)
 {
     return(_efcmd.Search(expression));
 }
Esempio n. 30
0
 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)));
 }