Example #1
0
 public bool UpdateEmail(MAILADRESS Entity)
 {
     using (KARYABDBEntities db = new KARYABDBEntities())
     {
         try
         {
             // var Skill = db.SKILLS.FirstOrDefault(q => q.ID == SkillID);
             db.MAILADRESSES.Attach(Entity);
             var Entry = db.Entry(Entity);
             Entry.State = EntityState.Modified;
             db.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Example #2
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);
         }
     }
 }
Example #3
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);
                }
            }
        }