public bool UpdatePackage(Package package) { using (var db = new CellDbContext()) { try { PackageDb packageToUpdate = db.Packages.SingleOrDefault(p => p.Id == package.Id); db.Entry(package).State = System.Data.Entity.EntityState.Modified; packageToUpdate = package.FromDTO(); db.SaveChanges(); return(true); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(false); } } }
public bool UpdateClient(Client client) { using (var db = new CellDbContext()) { try { ClientDb clientToUpdate = db.Clients.SingleOrDefault(c => c.ClientId == client.ClientId); db.Entry(client).State = System.Data.Entity.EntityState.Modified; clientToUpdate = client.FromDTO(); db.SaveChanges(); return(true); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(false); } } }
public bool UpdateClientLine(Line line) { using (var db = new CellDbContext()) { try { LineDb lineToUpdate = db.Lines.SingleOrDefault(l => l.ClientId == line.ClientId); db.Entry(lineToUpdate).State = System.Data.Entity.EntityState.Modified; lineToUpdate = line.FromDTO(); db.SaveChanges(); return(true); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(false); } } }
public bool RemoveClientLine(string number) { using (var db = new CellDbContext()) { try { LineDb lineToRemove = db.Lines.SingleOrDefault(l => l.Number == number); db.Lines.Remove(lineToRemove); db.Entry(lineToRemove).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); return(true); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(false); } } }
public Client AddClient(Client client) { using (var db = new CellDbContext()) { try { ClientDb newClient = client.FromDTO(); db.Clients.Add(newClient); db.Entry(newClient).State = System.Data.Entity.EntityState.Added; db.SaveChanges(); return(newClient.ToDTO()); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(null); } } }
public bool RemoveClient(string clientId) { using (var db = new CellDbContext()) { try { ClientDb clientToRemove = db.Clients.SingleOrDefault(c => c.ClientId == clientId); db.Clients.Remove(clientToRemove); db.Entry(clientToRemove).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); return(true); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(false); } } }
public bool UpdateClientType(ClientType clientType) { using (var db = new CellDbContext()) { try { ClientTypeDb TypeToUpdate = db.ClientTypes.Where(c => c.TypeName == clientType.TypeName).FirstOrDefault(); TypeToUpdate.ToDTO(); db.Entry(TypeToUpdate).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(true); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(false); } } }
public Package AddPackage(Package package) { using (var db = new CellDbContext()) { try { PackageDb newPackage; PackageDb packageDb = package.FromDTO(); newPackage = db.Packages.Add(packageDb); db.Entry(package).State = System.Data.Entity.EntityState.Added; db.SaveChanges(); return(newPackage.ToDTO()); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(null); } } }
public Line AddClientLine(Line line, string clientId) { using (var db = new CellDbContext()) { try { LineDb newLine = line.FromDTO(); newLine.ClientId = clientId; newLine = db.Lines.Add(newLine); db.Entry(newLine).State = System.Data.Entity.EntityState.Added; db.SaveChanges(); return(newLine.ToDTO()); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(null); } } }
public ClientType AddClientType(ClientType clientType) { using (var db = new CellDbContext()) { try { ClientTypeDb newType; ClientTypeDb typeDb = clientType.FromDTO(); newType = db.ClientTypes.Add(typeDb); db.Entry(newType).State = System.Data.Entity.EntityState.Added; db.SaveChanges(); return(newType.ToDTO()); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(null); } } }