//根据做法类型编码删除菜品做法类型,如果删除失败返回false,如果删除成功,则返回true public bool DeleteDischesWayName(int id) { //先判断是否存在有做法,如果有做法,则不能返回false DischesWayDataService odws = new DischesWayDataService(); List <DischesWay> orgDischesWay = odws.FindAllDischesWay(id); if (orgDischesWay != null) { return(false); } //删除 using (ChooseDishesEntities entities = new ChooseDishesEntities()) { DischesWayName booktype = new DischesWayName() { DischesWayNameId = id, }; DbEntityEntry <DischesWayName> entry = entities.Entry <DischesWayName>(booktype); entry.State = System.Data.EntityState.Deleted; entities.SaveChanges(); var newtype = entities.DischesWayName.SingleOrDefault(bt => bt.DischesWayNameId == id); if (newtype != null) { //Console.WriteLine(newtype.name); return(false); } else { //Console.WriteLine("No Found"); return(true); } } }
//根据做法类型编码删除菜品做法类型,如果删除失败返回false,如果删除成功,则返回true public bool DeleteDischesWayName(int id) { //先判断是否存在有做法,如果有做法,则不能返回false DischesWayDataService odws = new DischesWayDataService(); List<DischesWay> orgDischesWay = odws.FindAllDischesWay(id); if (orgDischesWay != null) { return false; } //删除 using (ChooseDishesEntities entities = new ChooseDishesEntities()) { DischesWayName booktype = new DischesWayName() { DischesWayNameId = id, }; DbEntityEntry<DischesWayName> entry = entities.Entry<DischesWayName>(booktype); entry.State = System.Data.EntityState.Deleted; entities.SaveChanges(); var newtype = entities.DischesWayName.SingleOrDefault(bt => bt.DischesWayNameId == id); if (newtype != null) { //Console.WriteLine(newtype.name); return false; } else { //Console.WriteLine("No Found"); return true; } } }
public void TestMethodupdateDischesWay() { DischesWayDataService dd = new DischesWayDataService(); DischesWay dw = new DischesWay() { DischesWayId = 1, DischesWayNameId = 2, UpdateDatetime = DateTime.Now, UpdateBy = 1, Code = 1, AddPrice = 2, Deleted = 0, Name = "三分熟", Status = 0, AddPriceByNum = 0, PingYing = "sfsjl", WayDetail = "要三分熟" }; var f = dd.UpdateDischesWay(dw); }
public void TestMethodDeleteDischesWay() { DischesWayDataService dd = new DischesWayDataService(); var f = dd.DeleteDischesWay(1); }