Example #1
0
        public bool UpdateRecallHospital(CommContracts.RecallHospital RecallHospital)
        {
            if (RecallHospital == null)
            {
                return(false);
            }
            using (DAL.HisContext ctx = new DAL.HisContext())
            {
                DAL.RecallHospital temp = new DAL.RecallHospital();
                temp = ctx.RecallHospitals.Find(RecallHospital.ID);
                if (temp == null)
                {
                    return(false);
                }

                temp.Reason          = RecallHospital.Reason;
                temp.LeaveHospitalID = RecallHospital.LeaveHospitalID;
                temp.RecallTime      = RecallHospital.RecallTime;
                temp.UserID          = RecallHospital.UserID;
                temp.CurrentTime     = RecallHospital.CurrentTime;

                try
                {
                    ctx.SaveChanges();
                }
#pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过
                catch (Exception ex)
#pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过
                {
                    return(false);
                }
            }
            return(true);
        }
Example #2
0
        public bool SaveRecallHospital(CommContracts.RecallHospital RecallHospital)
        {
            using (DAL.HisContext ctx = new DAL.HisContext())
            {
                var config2 = new MapperConfiguration(cfg =>
                {
                    cfg.CreateMap <CommContracts.RecallHospital, DAL.RecallHospital>().
                    ForMember(x => x.User, opt => opt.Ignore());
                });
                var mapper2 = config2.CreateMapper();

                var config = new MapperConfiguration(cfg =>
                {
                    cfg.CreateMap <CommContracts.RecallHospital, DAL.RecallHospital>();
                });
                var mapper = config.CreateMapper();


                DAL.RecallHospital temp = new DAL.RecallHospital();
                temp = mapper.Map <DAL.RecallHospital>(RecallHospital);

                ctx.RecallHospitals.Add(temp);
                try
                {
                    ctx.SaveChanges();
                }
#pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过
                catch (Exception ex)
#pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过
                {
                    return(false);
                }
            }
            return(true);
        }