public void NewBlog(Travelogue travelogue) { var context = new SiemensDBEntities(); context.Travelogues.Add(travelogue); context.SaveChanges(); }
public void Delete(int tiD) { var context = new SiemensDBEntities(); var selected = context.Travelogues.FirstOrDefault(t => t.TId == tiD); if (selected == null) { throw new Exception("Failed to Delete as no Travel Detail found"); } context.Travelogues.Remove(selected); context.SaveChanges(); }
public void Update(Travelogue travelogue) { var context = new SiemensDBEntities(); var selected = context.Travelogues.FirstOrDefault(t => t.TId == travelogue.TId); if (selected == null) { throw new Exception("Failed to update as no Travel Detail found"); } selected.Destination = travelogue.Destination; selected.Details = travelogue.Details; selected.NoOfDays = travelogue.NoOfDays; selected.TravelDate = travelogue.TravelDate; context.SaveChanges(); }