Exemple #1
0
        public TypeConsultationDeclarationTypeItem DeleteDeclarationType(TypeConsultationDeclarationTypeItem item)
        {
            try
            {
                TmpTypeConsultationDeclarationType entity = new TmpTypeConsultationDeclarationType
                {
                    ID = item.ID,
                    TypeConsultationDeclarationTypeID = item.TypeConsultationDeclarationTypeID,
                    TypeConsultationID  = item.TypeConsultationID,
                    DeclarationTypeID   = item.DeclarationTypeID,
                    DeclarationURL      = item.DeclarationURL,
                    DeclarationDeadline = item.DeclarationDeadline,
                    DeclarationDate     = item.DeclarationDate,
                    OrganizationID      = item.OrganizationID,
                    ResponseDate        = item.ResponseDate,
                    ResponseTypeID      = item.ResponseTypeID,
                    ResponseContent     = item.ResponseContent,
                    ResponseQualityID   = item.ResponseQualityID,
                    GUID = item.GUID
                };

                db.TmpTypeConsultationDeclarationTypes.Attach(entity);
                db.TmpTypeConsultationDeclarationTypes.Remove(entity);

                db.SaveChanges();
                return(item);
            }
            catch (Exception ex)
            {
                exception = ex;
                return(null);
            }
        }
Exemple #2
0
        public TypeConsultationDeclarationTypeItem UpdateDeclarationType(TypeConsultationDeclarationTypeItem item)
        {
            try
            {
                TmpTypeConsultationDeclarationType entity = new TmpTypeConsultationDeclarationType
                {
                    ID = item.ID,
                    TypeConsultationDeclarationTypeID = item.TypeConsultationDeclarationTypeID,
                    TypeConsultationID  = item.TypeConsultationID,
                    DeclarationTypeID   = item.DeclarationTypeID,
                    DeclarationURL      = item.DeclarationURL,
                    DeclarationDeadline = item.DeclarationDeadline,
                    DeclarationDate     = item.DeclarationDate,
                    OrganizationID      = item.OrganizationID,
                    ResponseDate        = item.ResponseDate,
                    ResponseTypeID      = item.ResponseTypeID,
                    ResponseContent     = item.ResponseContent,
                    ResponseQualityID   = item.ResponseQualityID,
                    GUID = item.GUID
                };

                db.TmpTypeConsultationDeclarationTypes.Attach(entity);
                db.Entry(entity).State = EntityState.Modified;

                db.SaveChanges();

                DeclarationType declarationType = db.DeclarationTypes.Find(item.DeclarationTypeID);
                Organization    organization    = db.Organizations.Find(item.OrganizationID);
                ResponseType    responseType    = db.ResponseTypes.Find(item.ResponseTypeID);
                //ResponseContent responseContent = db.ResponseContents.Find(item.ResponseContentID);
                ResponseQuality responseQuality = db.ResponseQualities.Find(item.ResponseQualityID);

                item.DeclarationTypeName = declarationType.DeclarationTypeName;
                item.OrganizationName    = organization.OrganizationName;
                item.ResponseTypeName    = responseType.ResponseTypeName;
                //item.ResponseContent = responseContent.ResponseContentName;
                item.ResponseQualityName = responseQuality.ResponseQualityName;

                return(item);
            }
            catch (Exception ex)
            {
                exception = ex;
                return(null);
            }
        }
Exemple #3
0
        public TypeConsultationDeclarationTypeItem InsertDeclarationType(TypeConsultationDeclarationTypeItem item)
        {
            try
            {
                TmpTypeConsultationDeclarationType entity = new TmpTypeConsultationDeclarationType
                {
                    TypeConsultationDeclarationTypeID = 0,
                    TypeConsultationID  = item.TypeConsultationID,
                    DeclarationTypeID   = item.DeclarationTypeID,
                    DeclarationURL      = item.DeclarationURL,
                    DeclarationDeadline = item.DeclarationDeadline,
                    DeclarationDate     = item.DeclarationDate,
                    OrganizationID      = item.OrganizationID,
                    ResponseDate        = item.ResponseDate,
                    ResponseTypeID      = item.ResponseTypeID,
                    ResponseContent     = item.ResponseContent,
                    ResponseQualityID   = item.ResponseQualityID,
                    GUID = item.GUID
                };

                db.TmpTypeConsultationDeclarationTypes.Add(entity);

                db.SaveChanges();

                item.ID = entity.ID;
                item.TypeConsultationDeclarationTypeID = entity.TypeConsultationDeclarationTypeID;

                DeclarationType declarationType = db.DeclarationTypes.Find(item.DeclarationTypeID);
                Organization    organization    = db.Organizations.Find(item.OrganizationID);
                ResponseType    responseType    = db.ResponseTypes.Find(item.ResponseTypeID);
                //ResponseContent responseContent = db.ResponseContents.Find(item.ResponseContentID);
                ResponseQuality responseQuality = db.ResponseQualities.Find(item.ResponseQualityID);

                //item.DeclarationTypeName = declarationType.DeclarationTypeName;
                //item.OrganizationName = organization.OrganizationName;
                //item.ResponseTypeName = responseType.ResponseTypeName;
                //item.ResponseContentName = responseContent.ResponseContentName;
                //item.ResponseQualityName = responseQuality.ResponseQualityName;

                if (item.DeclarationTypeID != null)
                {
                    item.DeclarationTypeName = declarationType.DeclarationTypeName;
                }
                if (item.OrganizationID != null)
                {
                    item.OrganizationName = organization.OrganizationName;
                }
                if (item.ResponseTypeID != null)
                {
                    item.ResponseTypeName = responseType.ResponseTypeName;
                }
                //if (item.ResponseContentID != null)
                //{
                //    item.ResponseContentName = responseContent.ResponseContentName;
                //}
                if (item.ResponseQualityID != null)
                {
                    item.ResponseQualityName = responseQuality.ResponseQualityName;
                }


                return(item);
            }
            catch (Exception ex)
            {
                exception = ex;
                return(null);
            }
        }