コード例 #1
0
ファイル: PericiaServico.cs プロジェクト: Silvao42/RPGFinal
        public NotificationResult Salvar(Pericia entidade)
        {
            var NotificationResult = new NotificationResult();

            try
            {
                if (entidade.CodPericia != 0)
                {
                    entidade.CodPericia = entidade.CodPericia;

                    if (NotificationResult.IsValid)
                    {
                        _periciaRepositorio.Adicionar(entidade);
                        NotificationResult.Add("Cadastrado!");
                    }

                    return(NotificationResult);
                }

                else
                {
                    return(NotificationResult.Add(new NotificationError("Erro no cadastro!", NotificationErrorType.USER)));
                };
            }

            catch (Exception ex)
            {
                return(NotificationResult.Add(new NotificationError(ex.Message)));
            }
        }
コード例 #2
0
ファイル: GeradorTestes.cs プロジェクト: pokenshin/Desire
        public void TesteGeraPericia()
        {
            GeradorPericia gerador = new GeradorPericia();
            Pericia        pericia = gerador.Gerar(rnd);

            Assert.IsNotNull(pericia);
        }
コード例 #3
0
        public ActionResult Form(int id)
        {
            if (!verifica_acesso("pericias", "Visualizar"))
            {
                return(RedirectToAction("Index", "Login"));
            }
            ViewBag.pagina = "Pericia / Detalhes";
            PericiaDao _PericiaDao = new PericiaDao();
            Pericia    _pericias   = new Pericia();

            if (id != 0)
            {
                _pericias = _PericiaDao.Listar_Pericia(id);
            }
            AtributoDao _AtributoDao = new AtributoDao();

            ViewBag.Atributos = _AtributoDao.Listar_Atributos_ativo();
            CampanhaDao _CampanhaDao = new CampanhaDao();

            ViewBag.Campanhas = _CampanhaDao.Listar_Campanhas_cb_mestre();
            ClasseDao _ClasseDao = new ClasseDao();

            ViewBag.Classes = _ClasseDao.Listar_Classes_dt_cb();
            return(View(_pericias));
        }
コード例 #4
0
ファイル: PericiaServico.cs プロジェクト: Silvao42/RPGFinal
        public NotificationResult Atualizar(Pericia entidade)
        {
            var NotificationResult = new NotificationResult();

            try
            {
                if (entidade.CodPericia != 0)
                {
                    entidade.CodPericia = entidade.CodPericia;
                }

                if (NotificationResult.IsValid)
                {
                    _periciaRepositorio.Atualizar(entidade);
                    NotificationResult.Add("Cadastro Alterado com Sucesso!");

                    return(NotificationResult);
                }

                else
                {
                    return(NotificationResult.Add(new NotificationError("O codigo informado não existe!", NotificationErrorType.USER)));
                }
            }
            catch (Exception)
            {
                return(NotificationResult.Add(new NotificationError("O codigo informado não existe!", NotificationErrorType.USER)));
            }
        }
コード例 #5
0
ファイル: PericiaServico.cs プロジェクト: Silvao42/RPGFinal
        public NotificationResult Excluir(Pericia entidade)
        {
            var NotificationResult = new NotificationResult();

            try
            {
                if (entidade.CodPericia != 0)
                {
                    if (NotificationResult.IsValid)
                    {
                        _periciaRepositorio.Remover(entidade);
                        NotificationResult.Add("Cadastro excluido com Sucesso!");

                        return(NotificationResult);
                    }

                    else
                    {
                        return(NotificationResult.Add(new NotificationError("O codigo informado não existe!", NotificationErrorType.USER)));
                    }
                }

                else
                {
                    return(NotificationResult.Add(new NotificationError("O codigo informado não existe!", NotificationErrorType.USER)));
                }
            }

            catch (Exception ex)
            {
                return(NotificationResult.Add(new NotificationError(ex.Message)));
            }
        }
コード例 #6
0
        public ActionResult DeleteConfirmed(int id)
        {
            Pericia pericia = db.Pericias.Find(id);

            db.Pericias.Remove(pericia);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #7
0
 public ActionResult Edit([Bind(Include = "PericiaId,Nome,Modificador,Mastery,Proeficiencia")] Pericia pericia)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pericia).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(pericia));
 }
コード例 #8
0
        public ActionResult Adiciona(int Cod_Pericia, string Descricao, int Cod_Atributo, int penalidade_peso, string requisito_classe, bool Treinada, string Caracteristicas, int Campanha, bool Ativo)
        {
            Pericia _Pericia = new Pericia();

            _Pericia.Cod_Pericia     = Cod_Pericia;
            _Pericia.Descricao       = Descricao;
            _Pericia.Cod_Atributo    = Cod_Atributo;
            _Pericia.penalidade_peso = penalidade_peso;
            if (string.IsNullOrEmpty(requisito_classe))
            {
                requisito_classe = "0";
            }
            _Pericia.requisito_classe = new List <int>(Array.ConvertAll(limpar_list(requisito_classe).Split('_'), int.Parse));
            _Pericia.Treinada         = Treinada;
            _Pericia.Caracteristicas  = Caracteristicas;
            _Pericia.Campanha         = Campanha;
            _Pericia.Ativo            = Ativo;

            string msg = validar(_Pericia);

            if (string.IsNullOrEmpty(msg))
            {
                PericiaDao _PericiaDao = new PericiaDao();
                if (_Pericia.Cod_Pericia == 0)
                {
                    if (verifica_acesso("Pericias", "Novo"))
                    {
                        msg = _PericiaDao.Insert(_Pericia);
                    }
                    else
                    {
                        msg = "Acesso não permitido";
                    }
                }
                else
                {
                    if (verifica_acesso("Pericias", "Alterar"))
                    {
                        msg = _PericiaDao.update(_Pericia);
                    }
                    else
                    {
                        msg = "Acesso não permitido";
                    }
                }
            }
            if (string.IsNullOrEmpty(msg))
            {
                return(Json(Url.Action("Index")));
            }
            else
            {
                return(Json(msg));
            }
        }
コード例 #9
0
        public ActionResult Create([Bind(Include = "PericiaId,Nome,Modificador,Mastery,Proeficiencia")] Pericia pericia)
        {
            if (ModelState.IsValid)
            {
                db.Pericias.Add(pericia);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pericia));
        }
コード例 #10
0
        // GET: Pericias/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Pericia pericia = db.Pericias.Find(id);

            if (pericia == null)
            {
                return(HttpNotFound());
            }
            return(View(pericia));
        }
コード例 #11
0
        public string validar(Pericia pericia)
        {
            PericiaDao _PericiaDao = new PericiaDao();
            string     msg         = "";

            if (string.IsNullOrEmpty(pericia.Descricao))
            {
                msg = "O Campo descrição é obrigatório.";
            }
            if (_PericiaDao.verificar_descricao(pericia.Descricao, pericia.Cod_Pericia))
            {
                msg = "A Pericia " + pericia.Descricao + " já existe.";
            }
            return(msg);
        }
コード例 #12
0
        public ActionResult Form(int id)
        {
            if (!verifica_acesso("pericias", "Visualizar"))
            {
                return(RedirectToAction("Index", "Login"));
            }
            ViewBag.pagina = "Pericia / Detalhes";
            PericiaDao    _PericiaDao = new PericiaDao();
            Pericia       _pericias   = new Pericia();
            List <string> Classesload = new List <string>();

            AtributoDao _AtributoDao = new AtributoDao();

            ViewBag.Atributos = _AtributoDao.Listar_Atributos_ativo();
            CampanhaDao _CampanhaDao = new CampanhaDao();

            ViewBag.Campanhas = _CampanhaDao.Listar_Campanhas_cb_mestre();
            ClasseDao _ClasseDao = new ClasseDao();

            List <Classe> listclas = _ClasseDao.Listar_Classes_dt_cb();

            ViewBag.Classes = listclas;

            if (id != 0)
            {
                _pericias = _PericiaDao.Listar_Pericia(id);

                foreach (int item in _pericias.requisito_classe)
                {
                    foreach (Classe _clas in listclas)
                    {
                        if (_clas.Cod_Classe == item)
                        {
                            Classesload.Add(_clas.Cod_Classe + "_" + _clas.Descricao);
                            break;
                        }
                    }
                }
            }
            else
            {
                _pericias.Ativo = true;
            }
            ViewBag.classesload = Classesload;
            return(View(_pericias));
        }
コード例 #13
0
        public void TesteAplicaModificadorModAdicionaPericia()
        {
            ser = new Ser();
            CalculadorMod calcMod = new CalculadorMod();
            Pericia       pericia = new Pericia()
            {
                Nome = "Pericia 1"
            };
            ModAdicionaPericia modificador = new ModAdicionaPericia()
            {
                Alvo   = pericia,
                Origem = "Teste"
            };

            calcMod.AplicaModificador(modificador, ser);

            Assert.IsTrue(ser.Pericias.Contains(pericia));
        }
コード例 #14
0
        public string update(Pericia pericia)
        {
            string msg = "";

            try
            {
                _conn   = new Conexao();
                _LogDao = new LogDao();

                string strupdate = "update vantagens set Descricao = '" + pericia.Descricao.Replace("'", "''") + "', Cod_Atributo = " + pericia.Cod_Atributo
                                   + ", penalidade_peso = " + pericia.penalidade_peso + ", requisito_classe = '" + string.Join <int>("_", pericia.requisito_classe).Replace("'", "''")
                                   + "', Treinada = '" + pericia.Treinada.ToString() + "', Caracteristicas = '" + pericia.Caracteristicas.Replace("'", "''") + "', Campanha = " + pericia.Campanha + ", Ativo = '" + pericia.Ativo.ToString() + "') ";
                _conn.execute(strupdate);
                _LogDao.insert("Pericia", "up", "cod_Pericia = " + pericia.Cod_Pericia.ToString());
            }
            catch (Exception)
            {
                msg = "Erro ao atualizar a Vantagem ('" + pericia.Descricao + "')";
            }
            return(msg);
        }
コード例 #15
0
        public string Insert(Pericia pericia)
        {
            string msg = "";

            try
            {
                _conn   = new Conexao();
                _LogDao = new LogDao();

                string strInsert = "insert into pericias (Descricao, Cod_Atributo, penalidade_peso, requisito_classe, Treinada, Caracteristicas, Campanha, Ativo) "
                                   + " values('" + pericia.Descricao.Replace("'", "''") + "', " + pericia.Cod_Atributo + ", " + pericia.penalidade_peso + ", '"
                                   + string.Join <int>("_", pericia.requisito_classe).Replace("'", "''") + "', '" + pericia.Treinada.ToString() + "', '" + pericia.Caracteristicas.Replace("'", "''") + "', "
                                   + pericia.Campanha + ", '" + pericia.Ativo.ToString() + "')";
                _conn.execute(strInsert);
                _LogDao.insert("Pericia", "add", "");
            }
            catch (Exception)
            {
                msg = "Erro ao adicionar a Vantagem ('" + pericia.Descricao + "')";
            }
            return(msg);
        }
コード例 #16
0
ファイル: PericiaDao.cs プロジェクト: rafaelcarraska/webrpg
        public Pericia Listar_Pericia(int cod_pericia)
        {
            _conn = new Conexao();
            Pericia _Pericia = new Pericia();

            DataTable dt_pericia = _conn.dataTable("select * from Pericias where cod_pericia = " + cod_pericia + "", "PERICIA");

            if (dt_pericia.Rows.Count > 0)
            {
                _Pericia.Cod_Pericia      = Convert.ToInt32(dt_pericia.Rows[0]["Cod_Pericia"].ToString());
                _Pericia.Descricao        = dt_pericia.Rows[0]["Descricao"].ToString();
                _Pericia.Cod_Atributo     = Convert.ToInt32(dt_pericia.Rows[0]["Cod_Atributo"].ToString());
                _Pericia.penalidade_peso  = Convert.ToInt32(dt_pericia.Rows[0]["penalidade_peso"].ToString());
                _Pericia.Campanha         = Convert.ToInt32(dt_pericia.Rows[0]["Campanha"].ToString());
                _Pericia.requisito_classe = new List <int>(Array.ConvertAll(dt_pericia.Rows[0]["requisito_classe"].ToString().Split('_'), int.Parse));
                _Pericia.Treinada         = Convert.ToBoolean(dt_pericia.Rows[0]["Treinada"].ToString());
                _Pericia.Caracteristicas  = dt_pericia.Rows[0]["Caracteristicas"].ToString();
                _Pericia.Campanha         = Convert.ToInt32(dt_pericia.Rows[0]["Campanha"].ToString());
                _Pericia.Ativo            = Convert.ToBoolean(dt_pericia.Rows[0]["Ativo"].ToString());
            }

            return(_Pericia);
        }
コード例 #17
0
 public NotificationResult Salvar(Pericia entidade)
 {
     return(_periciaServico.Salvar(entidade));
 }
コード例 #18
0
 public NotificationResult Excluir(Pericia entidade)
 {
     return(_periciaServico.Excluir(entidade));
 }
コード例 #19
0
 public NotificationResult Atualizar(Pericia entidade)
 {
     return(_periciaServico.Atualizar(entidade));
 }
コード例 #20
0
ファイル: PericiaController.cs プロジェクト: Gokinha/RPG
 public string Excluir(Pericia entidade)
 {
     return(pericia_Servico.Excluir(entidade));
 }
コード例 #21
0
 public NotificationResult Salvar(Pericia entidade)
 {
     throw new NotImplementedException();
 }