コード例 #1
0
        public bool UpdateLevelOneDepartment(CommContracts.LevelOneDepartment LevelOneDepartment)
        {
            using (DAL.HisContext ctx = new DAL.HisContext())
            {
                var temp = ctx.LevelOneDepartments.FirstOrDefault(m => m.ID == LevelOneDepartment.ID);
                if (temp != null)
                {
                    temp.Name       = LevelOneDepartment.Name;
                    temp.Abbr       = LevelOneDepartment.Abbr;
                    temp.UpdateTime = LevelOneDepartment.UpdateTime;
                }
                else
                {
                    return(false);
                }

                try
                {
                    ctx.SaveChanges();
                }
#pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过
                catch (Exception ex)
#pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #2
0
        public bool SaveLevelOneDepartment(CommContracts.LevelOneDepartment LevelOneDepartment)
        {
            using (DAL.HisContext ctx = new DAL.HisContext())
            {
                var config = new MapperConfiguration(cfg =>
                {
                    cfg.CreateMap <CommContracts.LevelOneDepartment, DAL.LevelOneDepartment>();
                });
                var mapper = config.CreateMapper();

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

                ctx.LevelOneDepartments.Add(temp);
                try
                {
                    ctx.SaveChanges();
                }
#pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过
                catch (Exception ex)
#pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #3
0
 public bool SaveLevelOneDepartment(CommContracts.LevelOneDepartment LevelOneDepartment)
 {
     return(client.SaveLevelOneDepartment(LevelOneDepartment));
 }