public bool CreateStore(StoreDAO s) { Store store = new Store { Store_ID = s.StoreID, Location = s.Location, Manager_ID = s.Manager_ID }; using (AESDatabaseDataContext db = new AESDatabaseDataContext()) { db.Stores.InsertOnSubmit(store); try { db.SubmitChanges(); } catch (Exception e) { throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message)); } } return true; }
public IList<StoreDAO> GetStores() { try { using (AESDatabaseDataContext db = new AESDatabaseDataContext()) { IList<Store> stores = db.Stores.ToList(); List<StoreDAO> result = new List<StoreDAO>(); foreach (var store in stores) { StoreDAO temp = new StoreDAO { ID = store.Store_ID, StoreID = store.Store_ID, Location = store.Location, Manager_ID = store.Manager_ID }; result.Add(temp); } return (result != null ? result : null); } } catch (Exception e) { throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message)); } }
public bool UpdateStore(StoreDAO newStore) { using (AESDatabaseDataContext db = new AESDatabaseDataContext()) { Store store = db.Stores.Single(s => s.Store_ID == newStore.StoreID); store.Location = newStore.Location; store.Manager_ID = newStore.Manager_ID; try { db.SubmitChanges(); } catch (Exception e) { throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message)); } } return true; }
public StoreDAO GetStoreByID(int id) { try { using (AESDatabaseDataContext db = new AESDatabaseDataContext()) { Store store = (from st in db.Stores where st.Store_ID == id select st).FirstOrDefault(); StoreDAO result = new StoreDAO { ID = store.Store_ID, StoreID = store.Store_ID, Location = store.Location, Manager_ID = store.Manager_ID }; return (result != null ? result : null); } } catch (Exception e) { throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message)); } }