예제 #1
0
 public long SetEmail(MAILADRESS Adress, long HumanID)
 {
     using (KARYABDBEntities db = new KARYABDBEntities())
     {
         try
         {
             db.Configuration.ProxyCreationEnabled = false;
             db.MAILADRESSES.Add(Adress);
             db.SaveChanges();
             OWNERSMAIL owenersAdress = new OWNERSMAIL();
             owenersAdress.MAILADRESSID = Adress.ID;
             owenersAdress.MAILOWNERID  = HumanID;
             db.OWNERSMAILS.Add(owenersAdress);
             db.SaveChanges();
             return(Adress.ID);
         }
         catch
         {
             return(0);
         }
     }
 }
예제 #2
0
        public bool DeleteEmail(MAILADRESS Entity)
        {
            using (KARYABDBEntities db = new KARYABDBEntities())
            {
                try
                {
                    db.Configuration.ProxyCreationEnabled = false;
                    MAILADRESS entity = db.MAILADRESSES.FirstOrDefault(q => q.ID == Entity.ID);
                    OWNERSMAIL Owner  = db.OWNERSMAILS.FirstOrDefault(q => q.MAILADRESSID == Entity.ID);
                    db.OWNERSMAILS.Attach(Owner);
                    db.OWNERSMAILS.Remove(Owner);
                    db.SaveChanges();
                    db.MAILADRESSES.Attach(entity);
                    db.MAILADRESSES.Remove(entity);
                    db.SaveChanges();

                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
        }