public long SetExperience(EXPERIENCE Experience, long HumanID) { using (KARYABDBEntities db = new KARYABDBEntities()) { try { db.Configuration.ProxyCreationEnabled = false; db.EXPERIENCES.Add(Experience); db.SaveChanges(); OWNERSEXPERIENCE owenersExperience = new OWNERSEXPERIENCE(); owenersExperience.EXPERIENCEID = Experience.ID; owenersExperience.EXPERIENCEOWNERID = HumanID; db.OWNERSEXPERIENCES.Add(owenersExperience); db.SaveChanges(); return(Experience.ID); } catch { return(0); } } }
public bool DeleteExperience(EXPERIENCE Entity) { using (KARYABDBEntities db = new KARYABDBEntities()) { try { db.Configuration.ProxyCreationEnabled = false; EXPERIENCE entity = db.EXPERIENCES.FirstOrDefault(q => q.ID == Entity.ID); OWNERSEXPERIENCE Owner = db.OWNERSEXPERIENCES.FirstOrDefault(q => q.EXPERIENCEID == Entity.ID); db.OWNERSEXPERIENCES.Attach(Owner); db.OWNERSEXPERIENCES.Remove(Owner); db.SaveChanges(); db.EXPERIENCES.Attach(entity); db.EXPERIENCES.Remove(entity); db.SaveChanges(); return(true); } catch (Exception e) { return(false); } } }