Пример #1
0
        public static bool __UpdateReason(FundamentoLegalTipoProcedimentoCcp fundamento)
        {
            if (fundamento == null)
            {
                return(false);
            }

            try
            {
                using (var _context = new SuchDBContext())
                {
                    _context.Update(fundamento);
                    _context.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Пример #2
0
        public static bool __CreateReason(FundamentoLegalTipoProcedimentoCcp fundamento)
        {
            if (fundamento == null)
            {
                return(false);
            }

            SuchDBContext _context = new SuchDBContext();

            try
            {
                FundamentoLegalTipoProcedimentoCcp LastFundamento = _context.FundamentoLegalTipoProcedimentoCcp
                                                                    .Where(f => f.IdTipo == fundamento.IdTipo)
                                                                    .OrderBy(t => t.IdTipo)
                                                                    .ThenBy(f => f.IdFundamento)
                                                                    .LastOrDefault();

                if (LastFundamento == null)
                {
                    fundamento.IdFundamento = 1;
                }
                else
                {
                    fundamento.IdFundamento = LastFundamento.IdFundamento + 1;
                }

                _context.Add(fundamento);
                _context.SaveChanges();
            }
            catch (Exception ex)
            {
                return(false);
            }

            return(true);
        }