public bool CreateAgency(TravelAgency agency) { bool success = true; try { using (var db = new EntryContext()) { if (db.TravelAgencies.FirstOrDefault(a => a.AgencyCode.Equals(agency.AgencyCode, StringComparison.CurrentCultureIgnoreCase)) != null) { success = false; } else { db.TravelAgencies.Add(agency); db.SaveChanges(); } } } catch (Exception ex) { success = false; Logs.Error("CreateAgency Exception : " + ex.ToString()); } return success; }
public bool DeleteAgencyByGuid(Guid guid) { bool success = true; try { using (var db = new EntryContext()) { var item = from a in db.TravelAgencies where a.ItemGuid == guid select a; db.TravelAgencies.Remove(item.FirstOrDefault()); db.SaveChanges(); } } catch (Exception ex) { success = false; Logs.Error("DeleteAgencyByGuid Exception : " + ex.ToString()); } return success; }
public bool DeleteTravelItem(Guid guid) { bool success = true; try { using (var db = new EntryContext()) { var items = from i in db.TravelItems where i.ItemGuid == guid select i; db.TravelItems.Remove(items.FirstOrDefault()); db.SaveChanges(); } } catch (Exception ex) { success = false; Logs.Error("DeleteTravelItem Exception : " + ex.ToString()); } return success; }
public bool UpdateAgency(TravelAgency a_agency) { bool success = true; try { using (var db = new EntryContext()) { db.Entry<TravelAgency>(a_agency).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } } catch (Exception ex) { success = false; Logs.Error("UpdateAgency Exception : " + ex.ToString()); } return success; }
public bool CreateTravelItem(TravelItem item) { bool success = true; try { using (var db = new EntryContext()) { db.TravelItems.Add(item); db.SaveChanges(); } } catch (Exception ex) { success = false; Logs.Error("CreateTravelItem Exception : " + ex.ToString()); } return success; }