public TelephoneModel UpdateTelephone(TelephoneModel telephoneModel) { _telephones.ReplaceOne(telephone => telephone.beforeTelephone.Equals(telephoneModel.beforeTelephone), telephoneModel); TelephoneModel tmpTelephoneModel = GetOneBeforeTelephone(telephoneModel.beforeTelephone); return(tmpTelephoneModel); }
static private MySqlCommand CreateSqlCommand(TelephoneModel telephoneModel, string commandText) { MySqlCommand command = new MySqlCommand(commandText); command.Parameters.AddWithValue("@beforeTelephone", telephoneModel.beforeTelephone); return(command); }
public static TelephoneModel ToObject(DataRow reader) { TelephoneModel telephoneModel = new TelephoneModel(); telephoneModel.beforeTelephone = reader[0].ToString(); Debug.WriteLine("TelephoneModel:" + telephoneModel.ToString()); return(telephoneModel); }
public TelephoneModel UpdateTelephone(TelephoneModel telephoneModel) { int i = -1; using (OleDbCommand command = new OleDbCommand()) { i = ExecuteNonQuery(TelephoneStringsInner.UpdateTelephone(telephoneModel)); } return(GetOneBeforeTelephone(telephoneModel.beforeTelephone)); }
static public MySqlCommand UpdateTelephone(TelephoneModel telephoneModel) { if (GlobalVariable.queryType == 0) { return(CreateSqlCommand(telephoneModel, queryTelephonesUpdate)); } else { return(CreateSqlCommand(telephoneModel, procedureTelephonesUpdate)); } }
public TelephoneModel AddTelephone(TelephoneModel telephoneModel) { if (GetOneBeforeTelephone(telephoneModel.beforeTelephone) == null) { _telephones.InsertOne(telephoneModel); } TelephoneModel tmpTelephoneModel = GetOneBeforeTelephone(telephoneModel.beforeTelephone); return(tmpTelephoneModel); }
public HttpResponseMessage GetOneBeforeTelephone(string beforeTelephone) { try { TelephoneModel telephoneModel = telephoneRepository.GetOneBeforeTelephone(beforeTelephone); return(Request.CreateResponse(HttpStatusCode.OK, telephoneModel)); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); return(Request.CreateResponse(HttpStatusCode.InternalServerError, errors)); } }
public TelephoneModel UpdateTelephone(TelephoneModel telephoneModel) { DataTable dt = new DataTable(); using (SqlCommand command = new SqlCommand()) { dt = GetMultipleQuery(TelephoneStringsSql.UpdateTelephone(telephoneModel)); } foreach (DataRow ms in dt.Rows) { telephoneModel = TelephoneModel.ToObject(ms); } return(telephoneModel); }
public List <TelephoneModel> GetAllTelephones() { DataTable dt = new DataTable(); using (SqlCommand command = new SqlCommand()) { dt = GetMultipleQuery(TelephoneStringsSql.GetAllTelephones()); } List <TelephoneModel> arrTelephone = new List <TelephoneModel>(); foreach (DataRow ms in dt.Rows) { arrTelephone.Add(TelephoneModel.ToObject(ms)); } return(arrTelephone); }
public HttpResponseMessage AddTelephone(TelephoneModel telephoneModel) { try { HttpResponseMessage hrm = new HttpResponseMessage(HttpStatusCode.Created) { Content = new StringContent(JsonConvert.SerializeObject(telephoneRepository.AddTelephone(telephoneModel))) }; return(hrm); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); HttpResponseMessage hr = new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(errors.ToString()) }; return(hr); } }
public TelephoneModel GetOneBeforeTelephone(string beforeTelephone) { DataTable dt = new DataTable(); if (beforeTelephone.Equals(string.Empty) || beforeTelephone.Equals("")) { throw new ArgumentOutOfRangeException(); } TelephoneModel telephoneModel = new TelephoneModel(); using (SqlCommand command = new SqlCommand()) { dt = GetMultipleQuery(TelephoneStringsSql.GetOneBeforeTelephone(beforeTelephone)); } foreach (DataRow ms in dt.Rows) { telephoneModel = TelephoneModel.ToObject(ms); } return(telephoneModel); }
public HttpResponseMessage UpdateCellphone(string beforeTelephone, TelephoneModel telephoneModel) { try { telephoneModel.beforeTelephone = beforeTelephone; HttpResponseMessage hrm = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(JsonConvert.SerializeObject(telephoneRepository.UpdateTelephone(telephoneModel))) }; return(hrm); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); HttpResponseMessage hr = new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(errors.ToString()) }; return(hr); } }
public TelephoneModel AddTelephone(TelephoneModel telephoneModel) { var resultSP = DB.AddTelephone(telephoneModel.beforeTelephone).Select(beforeTelephone2 => new TelephoneModel { beforeTelephone = beforeTelephone2 }); if (GlobalVariable.queryType == 0) { BeforeTelephone beforeTelephone = new BeforeTelephone { beforeTelephone1 = telephoneModel.beforeTelephone }; DB.BeforeTelephones.Add(beforeTelephone); DB.SaveChanges(); return(GetOneBeforeTelephone(beforeTelephone.beforeTelephone1)); } else { return(resultSP.SingleOrDefault()); } }
public TelephoneModel UpdateTelephone(TelephoneModel telephoneModel) { var resultSP = DB.UpdateTelephone(telephoneModel.beforeTelephone).Select(beforeTelephone2 => new TelephoneModel { beforeTelephone = beforeTelephone2 }); if (GlobalVariable.queryType == 0) { BeforeTelephone beforeTelephone = DB.BeforeTelephones.Where(t => t.beforeTelephone1.Equals(telephoneModel.beforeTelephone)).SingleOrDefault(); if (beforeTelephone == null) { return(null); } beforeTelephone.beforeTelephone1 = telephoneModel.beforeTelephone; DB.SaveChanges(); return(GetOneBeforeTelephone(beforeTelephone.beforeTelephone1)); } else { return(resultSP.SingleOrDefault()); } }
public HttpResponseMessage AddTelephone(TelephoneModel telephoneModel) { try { if (telephoneModel == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Data is null.")); } if (!ModelState.IsValid) { Errors errors = ErrorsHelper.GetErrors(ModelState); return(Request.CreateResponse(HttpStatusCode.BadRequest, errors)); } TelephoneModel addedTelephone = telephoneRepository.AddTelephone(telephoneModel); return(Request.CreateResponse(HttpStatusCode.Created, addedTelephone)); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); return(Request.CreateResponse(HttpStatusCode.InternalServerError, errors)); } }
public HttpResponseMessage UpdateTelephone(string beforeTelephone, TelephoneModel telephoneModel) { try { if (telephoneModel == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Data is null.")); } if (!ModelState.IsValid) { Errors errors = ErrorsHelper.GetErrors(ModelState); return(Request.CreateResponse(HttpStatusCode.BadRequest, errors)); } telephoneModel.beforeTelephone = beforeTelephone; TelephoneModel updatedTelephone = telephoneRepository.UpdateTelephone(telephoneModel); return(Request.CreateResponse(HttpStatusCode.OK, updatedTelephone)); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); return(Request.CreateResponse(HttpStatusCode.InternalServerError, errors)); } }
static public OleDbCommand AddTelephone(TelephoneModel telephoneModel) { return(CreateOleDbCommand(telephoneModel, queryTelephonesPost)); }
static public OleDbCommand UpdateTelephone(TelephoneModel telephoneModel) { return(CreateOleDbCommand(telephoneModel, queryTelephonesUpdate)); }