public bool RemoveByUsuario(int id)
 {
     using (var transaction = _context.Database.BeginTransaction())
     {
         try
         {
             var x = _context.Planejamento.Where(th => th.Usuario == id);
             if (x != null)
             {
                 _context.RemoveRange(x);
                 var save = _context.SaveChanges() == 1 ? true : false;
                 transaction.Commit();
                 return(save);
             }
             else
             {
                 throw new ServiceException("Algo deu errado, tente novamente em alguns minutos.");
             }
         }
         catch (Exception e)
         {
             transaction.Rollback();
             throw e;
         }
     }
 }
        public bool RemoveAll(List <CodigoInfravermelhoModel> codigoInfravermelhoModels)
        {
            var codigos = new List <Codigoinfravermelho>();

            codigoInfravermelhoModels.ForEach(c => codigos.Add(SetEntity(c)));
            _context.RemoveRange(codigos);
            return(_context.SaveChanges() == 1);
        }
示例#3
0
        public bool RemoveByIdPlanejamento(int idPlanejamento)
        {
            try
            {
                var x = _context.Horariosala.Where(th => th.Planejamento == idPlanejamento).ToList();
                if (x != null)
                {
                    _context.RemoveRange(x);
                    return(_context.SaveChanges() == 1);
                }
            }
            catch (Exception e)
            {
                throw new ServiceException("Houve um problema ao remover reservas associadas ao planejamento, por favor tente novamente mais tarde!");
            }

            return(false);
        }
示例#4
0
        public bool RemoveByUsuario(int id)
        {
            var x = _context.Usuarioorganizacao.Where(uo => uo.Usuario == id);

            if (x != null)
            {
                _context.RemoveRange(x);
                return(_context.SaveChanges() == 1 ? true : false);
            }

            return(false);
        }
示例#5
0
        public bool RemoveByUsuario(int id)
        {
            try
            {
                var x = _context.Salaparticular.Where(th => th.Usuario == id);
                if (x != null)
                {
                    _context.RemoveRange(x);
                    return(_context.SaveChanges() == 1 ? true : false);
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(false);
        }