public static Int64 Erstellen(DAL.Passwort passwort)
 {
     if (passwort.Login == null || passwort.Login == "")
     {
         passwort.Login = "******";
     }
     if (passwort.Zielsystem == null || passwort.Zielsystem == "")
     {
         passwort.Zielsystem = "leer";
     }
     if (passwort.PSW == null || passwort.PSW == "")
     {
         passwort.PSW = "leer";
     }
     // if (classA.TextAttribut == null) throw new Exception("Null ist ungültig");
     if (passwort.Eingabedatum == null)
     {
         passwort.Eingabedatum = DateTime.MinValue;
     }
     if (passwort.Ablaufdatum == null)
     {
         passwort.Ablaufdatum = DateTime.MinValue;
     }
     using (var context = new DAL.Context())
     {
         context.Passwort.Add(passwort);
         if (passwort.Kategorie != null)
         {
             context.Kategorie.Attach(passwort.Kategorie);
         }
         context.SaveChanges();
         return(passwort.PasswortId);
     }
 }
        public static void Aktualisieren(DAL.Passwort passwort)
        {
            using (var context = new DAL.Context())
            {
                context.Entry(passwort).State = System.Data.Entity.EntityState.Modified;
                context.SaveChanges();
            }

            using (var context = new DAL.Context())
            {
                var password = context.Passwort
                               .Include(i => i.Kategorie)
                               .FirstOrDefault(i => i.PasswortId == passwort.PasswortId);

                var category = context.Kategorie
                               .FirstOrDefault(i => i.KategorieId == passwort.Kategorie.KategorieId);

                if (category != null)
                {
                    context.Entry(password.Kategorie).State = EntityState.Modified;
                    context.Entry(password).State           = EntityState.Modified;
                    password.Kategorie = category;
                    context.SaveChanges();
                }
            }
        }
Beispiel #3
0
 public static void Aktualisieren(DAL.Passwort passwort)
 {
     using (var context = new DAL.Context())
     {
         context.Entry(passwort).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
 public static void Loeschen(DAL.Passwort passwort)
 {
     using (var context = new DAL.Context())
     {
         context.Entry(passwort).State = System.Data.Entity.EntityState.Deleted;
         context.Passwort.Remove(passwort);
         context.SaveChanges();
     }
 }
Beispiel #5
0
 public static void Loeschen(DAL.Passwort passwort)
 {
     using (var context = new DAL.Context())
     {
         var itemtoRemove = context.Passwort.FirstOrDefault(p => p.PasswortId == passwort.PasswortId);
         context.Passwort.Remove(itemtoRemove);
         context.SaveChanges();
     }
 }