//根据做法类型编码删除菜品做法类型,如果删除失败返回false,如果删除成功,则返回true public bool DeleteDishesWayNameByCode(int id) { if (id == null) { return(false); } //先判断是否存在有做法,如果有做法,则不能返回false DishesWayDataService odws = new DishesWayDataService(); List <DischesWay> orgDischesWay = odws.FindAllDishesWayByTypeId(id); if (orgDischesWay != null && orgDischesWay.Count > 0) { return(false); } //删除 using (ChooseDishesEntities entities = new ChooseDishesEntities()) { try { DischesWayName booktype = new DischesWayName() { DischesWayNameId = id, }; DbEntityEntry <DischesWayName> entry = entities.Entry <DischesWayName>(booktype); entry.State = System.Data.Entity.EntityState.Deleted; entities.SaveChanges(); return(true); } catch (Exception e) { e.ToString(); return(false); } } }
//根据做法类型编码删除菜品做法类型,如果删除失败返回false,如果删除成功,则返回true public bool DeleteDishesWayNameByCode(int id) { if (id == null) { return false; } //先判断是否存在有做法,如果有做法,则不能返回false DishesWayDataService odws = new DishesWayDataService(); List<DischesWay> orgDischesWay = odws.FindAllDishesWayByTypeId(id); if (orgDischesWay != null && orgDischesWay.Count > 0) { return false; } //删除 using (ChooseDishesEntities entities = new ChooseDishesEntities()) { try { DischesWayName booktype = new DischesWayName() { DischesWayNameId = id, }; DbEntityEntry<DischesWayName> entry = entities.Entry<DischesWayName>(booktype); entry.State = System.Data.Entity.EntityState.Deleted; entities.SaveChanges(); return true; } catch (Exception e) { e.ToString(); return false; } } }