示例#1
0
        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);
            }
        }
示例#2
0
        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);
            }
        }
示例#3
0
        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);
            }
        }