Exemple #1
0
 public static void Remover(int id)
 {
     using (BDRpgEntities context = new BDRpgEntities())
     {
         var produto_ = from Habilidades p in context.HabilidadesS
                        where p.Personagens.Id == id
                        select p;
         if (produto_.Count() > 0)
         {
             throw new RpgException(RpgExceptionCode.PERSONAGEMCOMHABILIDADES, id.ToString());
         }
         var categoria_ = from Personagens c in context.PersonagensS
                          where c.Id == id
                          select c;
         if (categoria_.Count() > 0)
         {
             context.PersonagensS.Remove(categoria_.First());
             context.SaveChanges();
         }
         else
         {
             throw new RpgException(RpgExceptionCode.PERSONAGEMIDINEXISTENTE, id.ToString());
         }
     }
 }
Exemple #2
0
 public static void Remover(int id)
 {
     using (BDRpgEntities context = new BDRpgEntities())
     {
         var habilidades_ = from Habilidades p in context.HabilidadesS
                            where p.Personagens.Id == id
                            select p;
         if (habilidades_.Count() > 0)
         {
             throw new RpgException(RpgExceptionCode.HABILIDADESCOMHABILIDADES, id.ToString());
         }
         var personagem_ = from Habilidades c in context.HabilidadesS
                           where c.Id == id
                           select c;
         if (personagem_.Count() > 0)
         {
             context.HabilidadesS.Remove(personagem_.First());
             context.SaveChanges();
         }
         else
         {
             throw new RpgException(RpgExceptionCode.HABILIDADESIDINEXISTENTE, id.ToString());
         }
     }
 }
Exemple #3
0
        public static List <Personagens> Listar()
        {
            List <Personagens> categorias = new List <Personagens>();

            using (BDRpgEntities context = new BDRpgEntities())
            {
                categorias.AddRange(context.PersonagensS);
            }
            return(categorias);
        }
Exemple #4
0
        public static List <Habilidades> Listar()
        {
            List <Habilidades> habilidades = new List <Habilidades>();

            using (BDRpgEntities context = new BDRpgEntities())
            {
                habilidades.AddRange(context.HabilidadesS);
            }
            return(habilidades);
        }
Exemple #5
0
        public static int Inserir(string nome)
        {
            int idNovo = -1;

            if (nome == null || nome.Length == 0)
            {
                throw new RpgException(RpgExceptionCode.PERSONAGEMNOMEVAZIO, "");
            }

            using (BDRpgEntities context = new BDRpgEntities())
            {
                Personagens c = new Personagens();
                c.Nome = nome;
                context.PersonagensS.Add(c);
                context.SaveChanges();
                idNovo = c.Id;
            }
            return(idNovo);
        }
Exemple #6
0
        public static int Inserir(string nome)
        {
            int idNovo = -1;

            if (nome == null || nome.Length == 0)
            {
                throw new RpgException(RpgExceptionCode.HABILIDADESNOMEVAZIO, "");
            }

            using (BDRpgEntities context = new BDRpgEntities())
            {
                Habilidades c = new Habilidades();
                c.Nome = nome;
                context.HabilidadesS.Add(c);
                context.SaveChanges();
                idNovo = c.Id;
            }
            return(idNovo);
        }
Exemple #7
0
        public static Personagens Consultar(int id)
        {
            Personagens categoria = null;

            using (BDRpgEntities context = new BDRpgEntities())
            {
                var categoria_ = from Personagens p in context.PersonagensS
                                 where p.Id == id
                                 select p;
                if (categoria_.Count() > 0)
                {
                    categoria = categoria_.First();
                }
                else
                {
                    throw new RpgException(RpgExceptionCode.PERSONAGEMIDINEXISTENTE, id.ToString());
                }
            }
            return(categoria);
        }
Exemple #8
0
        public static Habilidades Consultar(int id)
        {
            Habilidades habilidades = null;

            using (BDRpgEntities context = new BDRpgEntities())
            {
                var habilidades_ = from Habilidades h in context.HabilidadesS
                                   where h.Id == id
                                   select h;
                if (habilidades_.Count() > 0)
                {
                    habilidades = habilidades_.First();
                }
                else
                {
                    throw new RpgException(RpgExceptionCode.HABILIDADESIDINEXISTENTE, id.ToString());
                }
            }
            return(habilidades);
        }
Exemple #9
0
        public static void Atualizar(int id, string nome)
        {
            if (nome == null || nome.Length == 0)
            {
                throw new RpgException(RpgExceptionCode.PERSONAGEMNOMEVAZIO, "");
            }

            using (BDRpgEntities context = new BDRpgEntities())
            {
                var categoria_ = from Personagens c in context.PersonagensS
                                 where c.Id == id
                                 select c;
                if (categoria_.Count() > 0)
                {
                    Personagens c = categoria_.First();
                    c.Nome = nome;
                    context.SaveChanges();
                }
                else
                {
                    throw new RpgException(RpgExceptionCode.PERSONAGEMIDINEXISTENTE, id.ToString());
                }
            }
        }
Exemple #10
0
        public static void Atualizar(int id, string nome)
        {
            if (nome == null || nome.Length == 0)
            {
                throw new RpgException(RpgExceptionCode.HABILIDADESNOMEVAZIO, "");
            }

            using (BDRpgEntities context = new BDRpgEntities())
            {
                var habilidades_ = from Habilidades c in context.HabilidadesS
                                   where c.Id == id
                                   select c;
                if (habilidades_.Count() > 0)
                {
                    Habilidades c = habilidades_.First();
                    c.Nome = nome;
                    context.SaveChanges();
                }
                else
                {
                    throw new RpgException(RpgExceptionCode.HABILIDADESIDINEXISTENTE, id.ToString());
                }
            }
        }