Пример #1
0
 public void Atualizar(Ficha ficha)
 {
     using (var foc = new FichaOnlineContainer())
     {
         try
         {
             var fic   = foc.FichaSet.Where(f => f.Id == ficha.Id).SingleOrDefault();
             var props = ficha.GetType().GetProperties();
             foreach (var p in props)
             {
                 if (p.Name != "Peculiaridades" && p.Name != "PropriedadesRiquezasItensArmas" && p.Name != "Usuario")
                 {
                     if (p.GetValue(ficha, null) != null && p.GetValue(fic, null) != null)
                     {
                         var value = p.GetValue(ficha, null).ToString();
                         if (value != p.GetValue(fic, null).ToString())
                         {
                             p.SetValue(fic, p.GetValue(ficha, null), null);
                         }
                     }
                     else if (p.Name == "MestreId")
                     {
                         fic.MestreId = ficha.MestreId;
                     }
                 }
             }
             foc.SaveChanges();
         }
         catch (Exception ex)
         {
             throw new Exception("[FichaDao.Atualizar] -> " + ex.Message);
         }
     }
 }
Пример #2
0
 public List <string> SelecionarNomesRacas(string str)
 {
     using (var foc = new FichaOnlineContainer())
     {
         try
         {
             return(foc.FichaSet.Where(f => f.Raca.StartsWith(str)).Select(f => f.Raca).Distinct().ToList());
         }
         catch (Exception ex)
         {
             throw new Exception("[FichaDao.SelecionarNomesRacas] -> " + ex.Message);
         }
     }
 }
Пример #3
0
 public Ficha SelecionarPorId(int id)
 {
     using (var foc = new FichaOnlineContainer())
     {
         try
         {
             return(foc.FichaSet.Where(f => f.Id == id).SingleOrDefault());
         }
         catch (Exception ex)
         {
             throw new Exception("[FichaDao.SelecionarPorId] -> " + ex.Message);
         }
     }
 }
 public List <Peculiaridade> ListarPorTipo(string tipo)
 {
     using (var foc = new FichaOnlineContainer())
     {
         try
         {
             return(foc.PeculiaridadeSet.Where(p => p.Tipo == tipo).ToList());
         }
         catch (Exception ex)
         {
             throw new Exception("[PeculiaridadeDao.ListarPorTipo] -> " + ex.Message);
         }
     }
 }
Пример #5
0
 public List <string> SelecionarMestres(string str)
 {
     using (var foc = new FichaOnlineContainer())
     {
         try
         {
             return(foc.UsuarioSet.Where(u => u.Nome.StartsWith(str) || u.Email.StartsWith(str)).Select(u => u.Nome + ", " + u.Email).ToList());
         }
         catch (Exception ex)
         {
             throw new Exception("[UsuarioDao.SelecionarMestres] -> " + ex.Message);
         }
     }
 }
Пример #6
0
 public Usuario SelecionarPorEmail(string email)
 {
     using (var foc = new FichaOnlineContainer())
     {
         try
         {
             return(foc.UsuarioSet.Where(u => u.Email == email).SingleOrDefault());
         }
         catch (Exception ex)
         {
             throw new Exception("[UsuarioDao.SelecionarPorEmail] -> " + ex.Message);
         }
     }
 }
Пример #7
0
 public List <Usuario> Listar()
 {
     using (var foc = new FichaOnlineContainer())
     {
         try
         {
             return(foc.UsuarioSet.ToList());
         }
         catch (Exception ex)
         {
             throw new Exception("[UsuarioDao.Listar] -> " + ex.Message);
         }
     }
 }
 public List <string> SelecionarNomesPeculiaridades(string term, string tipo)
 {
     using (var foc = new FichaOnlineContainer())
     {
         try
         {
             return(foc.PeculiaridadeSet.Where(p => p.Nome.StartsWith(term) || p.Descricao.Contains(term)).Where(p => p.Tipo == tipo).Select(p => p.Nome).ToList());
         }
         catch (Exception ex)
         {
             throw new Exception("[PeculiaridadeDao.SelecionarNomesPeculiaridades] -> " + ex.Message);
         }
     }
 }
 public Peculiaridade SelecionarPorId(int id)
 {
     using (var foc = new FichaOnlineContainer())
     {
         try
         {
             return(foc.PeculiaridadeSet.Where(p => p.Id == id).SingleOrDefault());
         }
         catch (Exception ex)
         {
             throw new Exception("[PeculiaridadeDao.SelecionarPorId] -> " + ex.Message);
         }
     }
 }
Пример #10
0
 public List <string> SelecionarDescricoesPropriedadeRiqueza(string term, string tipo)
 {
     using (var foc = new FichaOnlineContainer())
     {
         try
         {
             return(foc.PropriedadeRiquezaItemArmaSet.Where(p => p.Descricao.StartsWith(term)).Where(p => p.Tipo == tipo).Select(p => p.Descricao).ToList());
         }
         catch (Exception ex)
         {
             throw new Exception("[PRIADao.SelecionarDescricoesPropriedadeRiqueza] -> " + ex.Message);
         }
     }
 }
Пример #11
0
 public List <Ficha> ListarPorMestreId(int mestreId)
 {
     using (var foc = new FichaOnlineContainer())
     {
         try
         {
             return(foc.FichaSet.Where(f => f.MestreId == mestreId && f.UsuarioId != mestreId && f.Pontos >= 0).ToList());
         }
         catch (Exception ex)
         {
             throw new Exception("[FichaDao.ListarPorMestreId] -> " + ex.Message);
         }
     }
 }
Пример #12
0
 public PropriedadeRiquezaItemArma SelecionarPorId(int id)
 {
     using (var foc = new FichaOnlineContainer())
     {
         try
         {
             return(foc.PropriedadeRiquezaItemArmaSet.Where(p => p.Id == id).SingleOrDefault());
         }
         catch (Exception ex)
         {
             throw new Exception("[PRIADao.ListarPorId] -> " + ex.Message);
         }
     }
 }
Пример #13
0
 public List <PropriedadeRiquezaItemArma> ListarPorFichaIdETipo(int fichaid, string tipo)
 {
     using (var foc = new FichaOnlineContainer())
     {
         try
         {
             return(foc.PropriedadeRiquezaItemArmaSet.Where(p => p.FichaId == fichaid && p.Tipo == tipo).ToList());
         }
         catch (Exception ex)
         {
             throw new Exception("[PRIADao.ListarPorFichaIdETipo] -> " + ex.Message);
         }
     }
 }
Пример #14
0
 public void Inserir(Peculiaridade peculiaridade)
 {
     using (var foc = new FichaOnlineContainer())
     {
         try
         {
             foc.PeculiaridadeSet.Add(peculiaridade);
             foc.SaveChanges();
         }
         catch (Exception ex)
         {
             throw new Exception("[PeculiaridadeDao.Inserir] -> " + ex.Message);
         }
     }
 }
Пример #15
0
 public void Inserir(PropriedadeRiquezaItemArma pria)
 {
     using (var foc = new FichaOnlineContainer())
     {
         try
         {
             foc.PropriedadeRiquezaItemArmaSet.Add(pria);
             foc.SaveChanges();
         }
         catch (Exception ex)
         {
             throw new Exception("[PRIADao.Inserir] -> " + ex.Message);
         }
     }
 }
Пример #16
0
 public void Inserir(Usuario usuario)
 {
     using (var foc = new FichaOnlineContainer())
     {
         try
         {
             usuario.DataCadastro = DateTime.Now.ToString();
             foc.UsuarioSet.Add(usuario);
             foc.SaveChanges();
         }
         catch (Exception ex)
         {
             throw new Exception("[UsuarioDao.Inserir] -> " + ex.Message);
         }
     }
 }
Пример #17
0
 public Usuario SelecionarPorId(int?id)
 {
     using (var foc = new FichaOnlineContainer())
     {
         try
         {
             if (id != null)
             {
                 return(foc.UsuarioSet.Where(u => u.Id == id).SingleOrDefault());
             }
             return(null);
         }
         catch (Exception ex)
         {
             throw new Exception("[UsuarioDao.SelecionarPorId] -> " + ex.Message);
         }
     }
 }
Пример #18
0
 public void Atualizar(Peculiaridade peculiaridade)
 {
     using (var foc = new FichaOnlineContainer())
     {
         try
         {
             var pec = foc.PeculiaridadeSet.Where(p => p.Id == peculiaridade.Id).SingleOrDefault();
             pec.Nome      = peculiaridade.Nome;
             pec.Descricao = peculiaridade.Descricao;
             pec.Teste     = peculiaridade.Teste;
             foc.SaveChanges();
         }
         catch (Exception ex)
         {
             throw new Exception("[PeculiaridadeDao.Atualizar] -> " + ex.Message);
         }
     }
 }
Пример #19
0
 public void Inserir(Ficha ficha)
 {
     using (var foc = new FichaOnlineContainer())
     {
         try
         {
             if (ficha.Nota == null)
             {
                 ficha.Nota = "";
             }
             foc.FichaSet.Add(ficha);
             foc.SaveChanges();
         }
         catch (Exception ex)
         {
             throw new Exception("[FichaDao.Inserir] -> " + ex.Message);
         }
     }
 }
Пример #20
0
 public void Atualizar(PropriedadeRiquezaItemArma pria)
 {
     using (var foc = new FichaOnlineContainer())
     {
         try
         {
             var prop = foc.PropriedadeRiquezaItemArmaSet.Where(p => p.Id == pria.Id).SingleOrDefault();
             prop.Nome           = pria.Nome;
             prop.Subtipo        = pria.Subtipo;
             prop.PesoQuantidade = pria.PesoQuantidade;
             prop.Descricao      = pria.Descricao;
             prop.ValorDano      = pria.ValorDano;
             foc.SaveChanges();
         }
         catch (Exception ex)
         {
             throw new Exception("[PRIADao.Atualizar] -> " + ex.Message);
         }
     }
 }