public OralConsultationRightItem InsertRight(OralConsultationRightItem item) { try { TmpOralConsultationRight entity = new TmpOralConsultationRight { OralConsultationRightID = 0, OralConsultationID = item.OralConsultationID, HumanRightID = item.HumanRightID, GUID = item.GUID }; db.TmpOralConsultationRights.Add(entity); db.SaveChanges(); item.ID = entity.ID; item.OralConsultationRightID = entity.OralConsultationRightID; HumanRight humanRight = db.HumanRights.Find(item.HumanRightID); item.HumanRightName = humanRight.HumanRightName; return(item); } catch (Exception ex) { exception = ex; return(null); } }
public OralConsultationRightItem UpdateRight(OralConsultationRightItem item) { try { TmpOralConsultationRight entity = new TmpOralConsultationRight { ID = item.ID, OralConsultationRightID = item.OralConsultationRightID, OralConsultationID = item.OralConsultationID, HumanRightID = item.HumanRightID, GUID = item.GUID }; db.TmpOralConsultationRights.Attach(entity); db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); HumanRight humanRight = db.HumanRights.Find(item.HumanRightID); item.HumanRightName = humanRight.HumanRightName; return(item); } catch (Exception ex) { exception = ex; return(null); } }
public OralConsultationRightItem DeleteRight(OralConsultationRightItem item) { try { TmpOralConsultationRight entity = new TmpOralConsultationRight { ID = item.ID, OralConsultationRightID = item.OralConsultationRightID, OralConsultationID = item.OralConsultationID, HumanRightID = item.HumanRightID, GUID = item.GUID }; db.TmpOralConsultationRights.Attach(entity); db.TmpOralConsultationRights.Remove(entity); db.SaveChanges(); return(item); } catch (Exception ex) { exception = ex; return(null); } }