Example #1
0
        public ActionResult SalvarSNPs(SNPs model)
        {
            //validação das informações para inserir
            model.Nome        = string.IsNullOrEmpty(model.Nome) ? "" : model.Nome;
            model.Localizacao = string.IsNullOrEmpty(model.Localizacao) ? "" : model.Localizacao;
            model.Mecanismo   = string.IsNullOrEmpty(model.Mecanismo) ? "" : model.Mecanismo;
            model.Ordem       = model.Ordem > 0 ? model.Ordem : 99;
            model.TargetGene  = string.IsNullOrEmpty(model.TargetGene) ? "" : model.TargetGene;
            model.ID_CANCER   = model.ID_CANCER > 0 ? model.ID_CANCER : 0;

            //insere ou não
            using (GENPsCEntities1 ent = new GENPsCEntities1())
            {
                if (model.ID > 0)//edit
                {
                    SNPs snps = ent.SNPs.SingleOrDefault(x => x.ID == model.ID);
                    snps.Nome        = model.Nome;
                    snps.Localizacao = model.Localizacao;
                    snps.Mecanismo   = model.Mecanismo;
                    snps.Ordem       = model.Ordem;
                    snps.TargetGene  = model.TargetGene;
                    snps.ID_CANCER   = model.ID_CANCER;
                }
                else //insert
                {
                    ent.SNPs.Add(model);
                }
                ent.SaveChanges();
            }

            return(RedirectToAction("SNPs"));
        }
Example #2
0
        public ActionResult ExcluirCategoria(int ID)
        {
            using (GENPsCEntities1 ent = new GENPsCEntities1())
            {
                Categoria cat = ent.Categoria.SingleOrDefault(x => x.ID == ID);
                ent.Categoria.Remove(cat);
                ent.SaveChanges();
            }

            return(RedirectToAction("Categoria"));
        }
Example #3
0
        public ActionResult ExcluirCancer(int ID)
        {
            using (GENPsCEntities1 ent = new GENPsCEntities1())
            {
                Cancer cancer = ent.Cancer.SingleOrDefault(x => x.ID == ID);
                ent.Cancer.Remove(cancer);
                ent.SaveChanges();
            }

            return(RedirectToAction("Cancer"));
        }
Example #4
0
        public ActionResult ExcluirSNPs(int ID)
        {
            using (GENPsCEntities1 ent = new GENPsCEntities1())
            {
                SNPs snps = ent.SNPs.SingleOrDefault(x => x.ID == ID);
                ent.SNPs.Remove(snps);
                ent.SaveChanges();
            }

            return(RedirectToAction("SNPs"));
        }
Example #5
0
        public ActionResult SalvarCategoria(Categoria model)
        {
            using (GENPsCEntities1 ent = new GENPsCEntities1())
            {
                if (model.ID > 0)//edit
                {
                    Categoria cat = ent.Categoria.SingleOrDefault(x => x.ID == model.ID);
                    cat.Nome = model.Nome;
                    cat.Cor  = model.Cor;
                }
                else //insert
                {
                    ent.Categoria.Add(model);
                }
                ent.SaveChanges();
            }

            return(RedirectToAction("Categoria"));
        }
Example #6
0
        public bool SalvaEstudo(string obj, bool valor, long idCancer)
        {
            //switcher_CAT_SNP
            try
            {
                var objSplit = obj.Split('_');
                var snp      = Convert.ToInt64(objSplit[2]);
                var sub      = Convert.ToInt64(objSplit[1]);
                if (valor)
                {
                    //insere na base
                    using (GENPsCEntities1 ent = new GENPsCEntities1())
                    {
                        REL_Cancer_x_Subcategoria_x_SNP rel = new REL_Cancer_x_Subcategoria_x_SNP
                        {
                            ID_CANCER       = idCancer,
                            ID_SNP          = snp,
                            ID_SUBCATEGORIA = sub
                        };

                        ent.REL_Cancer_x_Subcategoria_x_SNP.Add(rel);
                        ent.SaveChanges();
                    }
                }
                else // remove a informação
                {
                    using (GENPsCEntities1 ent = new GENPsCEntities1())
                    {
                        var rel = ent.REL_Cancer_x_Subcategoria_x_SNP.Single(x => x.ID_CANCER == idCancer &&
                                                                             x.ID_SNP == snp &&
                                                                             x.ID_SUBCATEGORIA == sub);
                        ent.REL_Cancer_x_Subcategoria_x_SNP.Remove(rel);
                        ent.SaveChanges();
                    }
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Example #7
0
        public ActionResult SalvarSubCategoria(Subcategoria model)
        {
            using (GENPsCEntities1 ent = new GENPsCEntities1())
            {
                if (model.ID > 0)//edit
                {
                    Subcategoria subcat = ent.Subcategoria.SingleOrDefault(x => x.ID == model.ID);
                    subcat.Nome         = model.Nome;
                    subcat.ID_CATEGORIA = model.ID_CATEGORIA;
                }
                else //insert
                {
                    ent.Subcategoria.Add(model);
                }
                ent.SaveChanges();
            }

            return(RedirectToAction("SubCategoria"));
        }
Example #8
0
        public ActionResult SalvarCancer(Cancer model, string listaSNPs, string listaCSC)
        {
            //validação das informações para inserir
            model.Nome = string.IsNullOrEmpty(model.Nome) ? "" : model.Nome;

            //insere ou não
            using (GENPsCEntities1 ent = new GENPsCEntities1())
            {
                if (model.ID > 0)//edit
                {
                    Cancer cancer = ent.Cancer.SingleOrDefault(x => x.ID == model.ID);
                    cancer.Nome = model.Nome;

                    //apagar todos
                    var todosCancerSNPs = ent.Cancer_x_SNP.ToList();
                    ent.Cancer_x_SNP.RemoveRange(todosCancerSNPs);
                    ent.SaveChanges();

                    //apagar todos cat e sub
                    var todosCancerCSC = ent.Cancer_x_Subcategoria.ToList();
                    ent.Cancer_x_Subcategoria.RemoveRange(todosCancerCSC);
                    ent.SaveChanges();

                    //inserir os novos selecionados snps
                    var s = listaSNPs.Split(',');
                    if (s != null && s.Count() > 0)
                    {
                        foreach (var item in s)
                        {
                            Cancer_x_SNP novo = new Cancer_x_SNP
                            {
                                ID_Cancer = model.ID,
                                ID_SNPS   = Convert.ToInt64(item)
                            };
                            ent.Cancer_x_SNP.Add(novo);
                            ent.SaveChanges();
                        }
                    }

                    //inserir os novos selecionados csc
                    var s2 = listaCSC.Split(',');
                    if (s2 != null && s.Count() > 0)
                    {
                        foreach (var item in s2)
                        {
                            Cancer_x_Subcategoria novo = new Cancer_x_Subcategoria
                            {
                                ID_CANCER       = model.ID,
                                ID_SUBCATEGORIA = Convert.ToInt64(item)
                            };
                            ent.Cancer_x_Subcategoria.Add(novo);
                            ent.SaveChanges();
                        }
                    }
                }
                else //insert
                {
                    ent.Cancer.Add(model);

                    //insere um novo snps
                    var s = listaSNPs.Split(',');
                    if (s != null && s.Count() > 0)
                    {
                        foreach (var item in s)
                        {
                            Cancer_x_SNP novo = new Cancer_x_SNP
                            {
                                ID_Cancer = model.ID,
                                ID_SNPS   = Convert.ToInt64(item)
                            };
                            ent.Cancer_x_SNP.Add(novo);
                            ent.SaveChanges();
                        }
                    }

                    //inserir os novos selecionados csc
                    var s2 = listaCSC.Split(',');
                    if (s2 != null && s.Count() > 0)
                    {
                        foreach (var item in s2)
                        {
                            Cancer_x_Subcategoria novo = new Cancer_x_Subcategoria
                            {
                                ID_CANCER       = model.ID,
                                ID_SUBCATEGORIA = Convert.ToInt64(item)
                            };
                            ent.Cancer_x_Subcategoria.Add(novo);
                            ent.SaveChanges();
                        }
                    }
                }
                ent.SaveChanges();
            }

            return(RedirectToAction("Cancer"));
        }