public Telephone UpdateTelephone(string idStr, Telephone telephone) { try { int id; if (!int.TryParse(idStr, out id)) { throw (new WebFaultException <Error>( new Error(string.Format("'{0}' is not a valid contact identifier", idStr)), HttpStatusCode.OK)); } if (database.GetContact(id) == null) { throw (new WebFaultException <Error>( new Error(string.Format("Telephone {0} not found", id)), HttpStatusCode.OK)); } database.UpdateTelephone(id, telephone.SubType, telephone.Number); return((Telephone)GetContact(idStr)); } catch (Exception ex) { throw MakeWebFaultException(ex); } }
public void UpdateTelephone(int id, string type, string number) { try { using (PartyEntities context = new PartyEntities(this.connectionString)) { Telephone telephone = (Telephone) (from t in context.Contacts where t.Id == id select t).First(); if (telephone != null) { telephone.Number = number; telephone.SubType = type; context.SaveChanges(); } } } catch (Exception ex) { if (ex is UpdateException) { throw ex.InnerException; } throw; } }
public int CreateTelephone(string type, string number) { try { using (PartyEntities context = new PartyEntities(this.connectionString)) { Telephone telephone = new Telephone(); telephone.Number = number; telephone.SubType = type; telephone.Type = "T"; context.Contacts.AddObject(telephone); context.SaveChanges(); return(telephone.Id); } } catch (Exception ex) { if (ex is UpdateException) { throw ex.InnerException; } throw; } }
public Telephone CreateTelephone(Telephone telephone) { try { int newId = database.CreateTelephone(telephone.SubType, telephone.Number); return((Telephone)GetContact(Convert.ToString(newId))); } catch (Exception ex) { throw MakeWebFaultException(ex); } }
public Telephone CreateTelephone(Telephone telephone) { try { int newId = database.CreateTelephone(telephone.SubType, telephone.Number); return (Telephone)GetContact(Convert.ToString(newId)); } catch (Exception ex) { throw MakeWebFaultException(ex); } }
public Telephone UpdateTelephone(string idStr, Telephone telephone) { try { int id; if (!int.TryParse(idStr, out id)) { throw (new WebFaultException<Error>( new Error(string.Format("'{0}' is not a valid contact identifier", idStr)), HttpStatusCode.OK)); } if (database.GetContact(id) == null) { throw (new WebFaultException<Error>( new Error(string.Format("Telephone {0} not found", id)), HttpStatusCode.OK)); } database.UpdateTelephone(id, telephone.SubType, telephone.Number); return (Telephone)GetContact(idStr); } catch (Exception ex) { throw MakeWebFaultException(ex); } }
public int CreateTelephone(string type, string number) { try { using (PartyEntities context = new PartyEntities(this.connectionString)) { Telephone telephone = new Telephone(); telephone.Number = number; telephone.SubType = type; telephone.Type = "T"; context.Contacts.AddObject(telephone); context.SaveChanges(); return telephone.Id; } } catch (Exception ex) { if (ex is UpdateException) { throw ex.InnerException; } throw; } }