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); }
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); }
public bool SaveLevelOneDepartment(CommContracts.LevelOneDepartment LevelOneDepartment) { return(client.SaveLevelOneDepartment(LevelOneDepartment)); }