Exemple #1
0
        public CnDrug Get(string id)
        {
            using (CnDrugDAL dal = new CnDrugDAL())
            {
                DUG_CNDRUG entitys = dal.Get(p => p.ID == id);

                return(EntityToModel(entitys));
            }
        }
Exemple #2
0
        public bool Edit(CnDrug model)
        {
            using (CnDrugDAL dal = new CnDrugDAL())
            {
                if (model == null)
                {
                    return(false);
                }

                DUG_CNDRUG entitys = ModelToEntity(model);
                entitys.CREATEDATETIME = DateTime.Now;

                return(dal.Edit(entitys));
            }
        }
Exemple #3
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string Add(CnDrug model)
        {
            if (model == null)
            {
                return(string.Empty);
            }
            using (CnDrugDAL dal = new CnDrugDAL())
            {
                DUG_CNDRUG entity = ModelToEntity(model);
                entity.ID             = string.IsNullOrEmpty(model.ID) ? Guid.NewGuid().ToString("N") : model.ID;
                entity.CREATEDATETIME = (model.CreateDateTime != null && model.CreateDateTime.HasValue) ? model.CreateDateTime.Value : DateTime.Now;

                return(dal.Add(entity));
            }
        }
Exemple #4
0
        /// <summary>
        /// Entity转Model
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        private CnDrug EntityToModel(DUG_CNDRUG entity)
        {
            if (entity != null)
            {
                CnDrug model = new CnDrug()
                {
                    ID                 = entity.ID,
                    DrugBankID         = entity.DRUGBANKID,
                    Name               = entity.NAME,
                    PinyinCode         = entity.PINYINCODE,
                    EnName             = entity.ENNAME,
                    CommonName         = entity.COMMONNAME,
                    TypeName           = entity.TYPENAME,
                    KindName           = entity.KINDNAME,
                    IsPrescription     = entity.ISPRESCRIPTION,
                    IsMedicalInsurance = entity.ISMEDICALINSURANCE,
                    Company            = entity.COMPANY,
                    Pack               = entity.PACK,
                    DosageForms        = entity.DOSAGEFORMS,
                    Dosage             = entity.DOSAGE,
                    Description        = entity.DESCRIPTION,
                    Indication         = entity.INDICATION,
                    Content            = entity.CONTENT,
                    Price              = entity.PRICE,
                    Contraindication   = entity.CONTRAINDICATION,
                    Notice             = entity.NOTICE,
                    Adverse            = entity.ADVERSE,
                    CreateUserID       = entity.CREATEUSERID,
                    CreateUserName     = entity.CREATEUSERNAME,
                    CreateDateTime     = entity.CREATEDATETIME,
                    EditUserID         = entity.EDITUSERID,
                    EditUserName       = entity.EDITUSERNAME,
                    EditTime           = entity.EDITDATETIME,
                    OwnerID            = entity.OWNERID,
                    OwnerName          = entity.OWNERNAME,
                    IsDeleted          = entity.ISDELETED
                };

                return(model);
            }

            return(null);
        }
Exemple #5
0
        /// <summary>
        /// Model转Entity
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private DUG_CNDRUG ModelToEntity(CnDrug model)
        {
            if (model != null)
            {
                DUG_CNDRUG entity = new DUG_CNDRUG()
                {
                    ID                 = model.ID,
                    DRUGBANKID         = model.DrugBankID,
                    NAME               = model.Name,
                    PINYINCODE         = model.PinyinCode,
                    ENNAME             = model.EnName,
                    COMMONNAME         = model.CommonName,
                    TYPENAME           = model.TypeName,
                    KINDNAME           = model.KindName,
                    ISPRESCRIPTION     = model.IsPrescription,
                    ISMEDICALINSURANCE = model.IsMedicalInsurance,
                    COMPANY            = model.Company,
                    PACK               = model.Pack,
                    DOSAGEFORMS        = model.DosageForms,
                    DOSAGE             = model.Dosage,
                    DESCRIPTION        = model.Description,
                    INDICATION         = model.Indication,
                    CONTENT            = model.Content,
                    PRICE              = model.Price,
                    CONTRAINDICATION   = model.Contraindication,
                    NOTICE             = model.Notice,
                    ADVERSE            = model.Adverse,
                    CREATEUSERID       = model.CreateUserID,
                    CREATEUSERNAME     = model.CreateUserName,
                    CREATEDATETIME     = model.CreateDateTime,
                    EDITUSERID         = model.EditUserID,
                    EDITUSERNAME       = model.EditUserName,
                    EDITDATETIME       = model.EditTime,
                    OWNERID            = model.OwnerID,
                    OWNERNAME          = model.OwnerName,
                    ISDELETED          = model.IsDeleted
                };

                return(entity);
            }
            return(null);
        }