예제 #1
0
        public static void Atualizar(int id_aluno, String nome, String telefone)
        {
            Model1Container contexto = new Model1Container();
            Alunos          a        = contexto.AlunosSet.Find(id_aluno);

            a.Nome     = nome;
            a.Telefone = telefone;
            contexto.AlunosSet.Attach(a);
            contexto.Entry(a).State = EntityState.Modified;
            contexto.SaveChanges();
        }
예제 #2
0
 public bool AddComment()
 {
     using (Model1Container ctx = new Model1Container())
     {
         bool bResult = false;
         if (this == null || this.PostPostId == 0)
         {
             return(bResult);
         }
         if (this.CommentId == 0)
         {
             ctx.Entry <Comment>(this).State = EntityState.Added;
             Post p = ctx.Posts.Find(this.PostPostId);
             ctx.Entry <Post>(p).State = EntityState.Unchanged;
             ctx.SaveChanges();
             bResult = true;
         }
         return(bResult);
     }
 }
예제 #3
0
 public bool AddPost()
 {
     using (Model1Container ctx = new Model1Container())
     {
         bool bResult = false;
         if (this.PostId == 0)
         {
             var it = ctx.Entry <Post>(this).State = EntityState.Added;
             ctx.SaveChanges();
             bResult = true;
         }
         return(bResult);
     }
 }
예제 #4
0
 public bool UpdateCompany(Company companyfromVM)
 {
     Company company;
     bool succes = true;
     try
     {
         using (Model1Container context = new Model1Container())
         {
             company = context.Company.Find(companyfromVM.ID);
             context.Entry(company).CurrentValues.SetValues(companyfromVM);
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         succes = false;
     }
     return succes;
 }