コード例 #1
0
        public static Int64 Create(Citizen citizen)
        {
            if (citizen.name == null)
            {
                citizen.name = "";
            }
            if (citizen.firstName == null)
            {
                citizen.firstName = "";
            }
            if (citizen.gender == null)
            {
                citizen.gender = "";
            }
            if (citizen.birthday == null)
            {
                citizen.birthday = DateTime.Today;
            }
            if (citizen.incomePerMonth == null)
            {
                citizen.incomePerMonth = 0;
            }
            if (citizen.fk_buildingID == null)
            {
                citizen.fk_buildingID = 1;
            }

            using (var db = new M120_ProjektEntities())
            {
                db.Citizens.Add(citizen);
                db.SaveChanges();
                db.Entry(citizen).Reload();
                return(citizen.citizenID);
            }
        }
コード例 #2
0
 public static Int64 Create(Building building)
 {
     if (building.name == null)
     {
         building.name = "";
     }
     if (building.street == null)
     {
         building.street = "";
     }
     if (building.streetNr == null)
     {
         building.streetNr = "0";
     }
     if (building.place == null)
     {
         building.place = "";
     }
     if (building.purpose == null)
     {
         building.purpose = "";
     }
     using (var db = new M120_ProjektEntities())
     {
         db.Buildings.Add(building);
         db.SaveChanges();
         db.Entry(building).Reload();
         return(building.BuildingID);
     }
 }
コード例 #3
0
 public static void Delete(Building building)
 {
     using (var db = new M120_ProjektEntities())
     {
         db.Entry(building).State = System.Data.Entity.EntityState.Deleted;
         db.SaveChanges();
     }
 }
コード例 #4
0
 public static void Delete(Citizen citizen)
 {
     using (var db = new M120_ProjektEntities())
     {
         db.Entry(citizen).State = System.Data.Entity.EntityState.Deleted;
         db.SaveChanges();
     }
 }