public OralConsultationOrganizationItem InsertOrganization(OralConsultationOrganizationItem item) { try { TmpOralConsultationOrganization entity = new TmpOralConsultationOrganization { OralConsultationOrganizationID = 0, OralConsultationID = item.OralConsultationID, OrganizationID = item.OrganizationID, GUID = item.GUID }; db.TmpOralConsultationOrganizations.Add(entity); db.SaveChanges(); item.ID = entity.ID; item.OralConsultationOrganizationID = entity.OralConsultationOrganizationID; Organization organization = db.Organizations.Find(item.OrganizationID); item.OrganizationName = organization.OrganizationName; return(item); } catch (Exception ex) { exception = ex; return(null); } }
public OralConsultationOrganizationItem UpdateOrganization(OralConsultationOrganizationItem item) { try { TmpOralConsultationOrganization entity = new TmpOralConsultationOrganization { ID = item.ID, OralConsultationOrganizationID = item.OralConsultationOrganizationID, OralConsultationID = item.OralConsultationID, OrganizationID = item.OrganizationID, GUID = item.GUID }; db.TmpOralConsultationOrganizations.Attach(entity); db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); Organization organization = db.Organizations.Find(item.OrganizationID); item.OrganizationName = organization.OrganizationName; return(item); } catch (Exception ex) { exception = ex; return(null); } }
public OralConsultationOrganizationItem DeleteOrganization(OralConsultationOrganizationItem item) { try { TmpOralConsultationOrganization entity = new TmpOralConsultationOrganization { ID = item.ID, OralConsultationOrganizationID = item.OralConsultationOrganizationID, OralConsultationID = item.OralConsultationID, OrganizationID = item.OrganizationID, GUID = item.GUID }; db.TmpOralConsultationOrganizations.Attach(entity); db.TmpOralConsultationOrganizations.Remove(entity); db.SaveChanges(); return(item); } catch (Exception ex) { exception = ex; return(null); } }