public tblSchedule SaveItem(tblSchedule scheduleItem) { try { UpdateLineBus(scheduleItem.LineId, scheduleItem.BusId); //BusProjectEntities db = new BusProjectEntities(); DB.tblSchedules.Add(scheduleItem); DB.SaveChanges(); return(scheduleItem); } catch (Exception ex) { Console.WriteLine(ex); } return(null); }
public bool Update(tblSchedule scheduleItem) { var res = false; try { UpdateLineBus(scheduleItem.LineId, scheduleItem.BusId); BusProjectEntities db = new BusProjectEntities(); db.Entry(scheduleItem).State = EntityState.Modified; db.SaveChanges(); res = true; } catch (Exception ex) { Console.WriteLine(ex); } return(res); }