예제 #1
0
 public PartInformation Read(int id)
 {
     using (var db = new LifestyleCheckerContext())
     {
         return(db.PartInformations.Include(journal => journal.Journal).FirstOrDefault(schoolEvent => schoolEvent.Id == id));
     }
 }
예제 #2
0
 public Journal Read(int id)
 {
     using (var db = new LifestyleCheckerContext())
     {
         return(db.Journals.Include(journal => journal.PartInformations).FirstOrDefault(journal => journal.Id == id));
     }
 }
예제 #3
0
 public bool Delete(PartInformation item)
 {
     using (var db = new LifestyleCheckerContext())
     {
         db.Entry(item).State = System.Data.Entity.EntityState.Deleted;
         db.SaveChanges();
         return(Read(item.Id) == null);
     }
 }
예제 #4
0
 public PartInformation Update(PartInformation item)
 {
     using (var db = new LifestyleCheckerContext())
     {
         db.Entry(item).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(item);
     }
 }
예제 #5
0
 public Journal Update(Journal item)
 {
     using (var db = new LifestyleCheckerContext())
     {
         db.Entry(item).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(item);
     }
 }
예제 #6
0
 public List <Journal> ReadAll()
 {
     using (var db = new LifestyleCheckerContext())
     {
         if (db.Journals != null)
         {
             return(db.Journals.Include(journal => journal.PartInformations).ToList());
         }
         return(new List <Journal>());
     }
 }
예제 #7
0
        public List <PartInformation> ReadAll()
        {
            using (var db = new LifestyleCheckerContext())
            {
                if (db.PartInformations != null)
                {
                    return(db.PartInformations.Include(partInformation => partInformation.Journal).ToList());
                }

                return(new List <PartInformation>());
            }
        }
예제 #8
0
        public PartInformation Create(PartInformation item)
        {
            using (var db = new LifestyleCheckerContext())
            {
                if (db.PartInformations == null)
                {
                    return(null);
                }


                item.Journal = db.Journals.Include(journal => journal.PartInformations).FirstOrDefault(journal => journal.Id == item.Journal.Id);

                db.PartInformations.Add(item);
                db.SaveChanges();
                return(item);
            }
        }
예제 #9
0
 public Journal Create(Journal item)
 {
     using (var db = new LifestyleCheckerContext())
     {
         if (db.Journals == null)
         {
             return(null);
         }
         foreach (var partInformation in item.PartInformations)
         {
             db.Entry(partInformation).State = EntityState.Unchanged;
         }
         db.Journals.Add(item);
         db.SaveChanges();
         return(item);
     }
 }