Exemple #1
0
 public static long AddBirth(Birth birth)
 {
     try
     {
         using (EZER_LAYOLEDETEntities db = new EZER_LAYOLEDETEntities())
         {
             var newBirth = db.Birth.Add(birth);
             db.SaveChanges();
             return(newBirth.UserId);
         }
     }
     catch
     {
         throw;
     }
 }
Exemple #2
0
        public static long AddMother(Mother mother, Birth birth, Kosher kosher1 = null, Kosher kosher2 = null, Kosher kosher3 = null)
        {
            try
            {
                using (EZER_LAYOLEDETEntities db = new EZER_LAYOLEDETEntities())
                {
                    var user = db.Users.Add(mother.Users);
                    //var newKosher1 = db.Kosher.Add(kosher1);
                    //var newKosher2 = db.Kosher.Add(kosher2);
                    //var newKosher3 = db.Kosher.Add(kosher3);

                    var newMother = db.Mother.Add(mother);

                    //db.SaveChanges();
                    var newBirth = db.Birth.Add(birth);
                    newMother.Birth.Add(newBirth);


                    //newMother.Users = user;
                    //newMother.UserId = user.UserId;
                    //newMother.Kosher1 = newKosher1.KosherId;
                    //newMother.Kosher2 = newKosher2.KosherId;
                    //newMother.Kosher3 = newKosher3.KosherId;
                    //newMother.Kosher = newKosher1;
                    //newMother.Kosher4 = newKosher2;
                    //newMother.Kosher5 = newKosher3;


                    db.SaveChanges();

                    return(newMother.UserId);
                }
            }
            catch (Exception ex)
            {
                throw new Exception();
            }
        }