public CellphoneModel UpdateCellphone(CellphoneModel cellphoneModel) { _cellphone.ReplaceOne(cellphone => cellphone.beforeCellphone.Equals(cellphoneModel.beforeCellphone), cellphoneModel); CellphoneModel tmpCellphoneModel = GetOneBeforeCellphone(cellphoneModel.beforeCellphone); return(tmpCellphoneModel); }
static private OleDbCommand CreateOleDbCommand(CellphoneModel cellphoneModel, string commandText) { OleDbCommand command = new OleDbCommand(commandText); command.Parameters.AddWithValue("@beforeCellphone", cellphoneModel.beforeCellphone); return(command); }
public static CellphoneModel ToObject(DataRow reader) { CellphoneModel cellphoneModel = new CellphoneModel(); cellphoneModel.beforeCellphone = reader[0].ToString(); Debug.WriteLine("CellphoneModel:" + cellphoneModel.ToString()); return(cellphoneModel); }
public CellphoneModel UpdateCellphone(CellphoneModel cellphoneModel) { int i = -1; using (OleDbCommand command = new OleDbCommand()) { i = ExecuteNonQuery(CellphoneStringsInner.UpdateCellphone(cellphoneModel)); } return(GetOneBeforeCellphone(cellphoneModel.beforeCellphone)); }
public CellphoneModel AddCellphone(CellphoneModel cellphoneModel) { if (GetOneBeforeCellphone(cellphoneModel.beforeCellphone) == null) { _cellphone.InsertOne(cellphoneModel); } CellphoneModel tmpCellphoneModel = GetOneBeforeCellphone(cellphoneModel.beforeCellphone); return(tmpCellphoneModel); }
static public SqlCommand UpdateCellphone(CellphoneModel cellphoneModel) { if (GlobalVariable.queryType == 0) { return(CreateSqlCommand(cellphoneModel, queryCellphonesUpdate)); } else { return(CreateSqlCommand(cellphoneModel, procedureCellphonesUpdate)); } }
public HttpResponseMessage GetOneBeforeCellphone(string beforeCellphone) { try { CellphoneModel cellphoneModel = cellphoneRepository.GetOneBeforeCellphone(beforeCellphone); return(Request.CreateResponse(HttpStatusCode.OK, cellphoneModel)); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); return(Request.CreateResponse(HttpStatusCode.InternalServerError, errors)); } }
public CellphoneModel UpdateCellphone(CellphoneModel cellphoneModel) { DataTable dt = new DataTable(); using (SqlCommand command = new SqlCommand()) { dt = GetMultipleQuery(CellphoneStringsSql.UpdateCellphone(cellphoneModel)); } foreach (DataRow ms in dt.Rows) { cellphoneModel = CellphoneModel.ToObject(ms); } return(cellphoneModel); }
public List <CellphoneModel> GetAllCellphones() { DataTable dt = new DataTable(); using (SqlCommand command = new SqlCommand()) { dt = GetMultipleQuery(CellphoneStringsSql.GetAllCellphones()); } List <CellphoneModel> arrCellphone = new List <CellphoneModel>(); foreach (DataRow ms in dt.Rows) { arrCellphone.Add(CellphoneModel.ToObject(ms)); } return(arrCellphone); }
public HttpResponseMessage AddCellphone(CellphoneModel cellphoneModel) { try { HttpResponseMessage hrm = new HttpResponseMessage(HttpStatusCode.Created) { Content = new StringContent(JsonConvert.SerializeObject(cellphoneRepository.AddCellphone(cellphoneModel))) }; return(hrm); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); HttpResponseMessage hr = new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(errors.ToString()) }; return(hr); } }
public CellphoneModel GetOneBeforeCellphone(string beforeCellphone) { DataTable dt = new DataTable(); if (beforeCellphone.Equals(string.Empty) || beforeCellphone.Equals("")) { throw new ArgumentOutOfRangeException(); } CellphoneModel cellphoneModel = new CellphoneModel(); using (SqlCommand command = new SqlCommand()) { dt = GetMultipleQuery(CellphoneStringsSql.GetOneBeforeCellphone(beforeCellphone)); } foreach (DataRow ms in dt.Rows) { cellphoneModel = CellphoneModel.ToObject(ms); } return(cellphoneModel); }
public HttpResponseMessage AddCellphone(CellphoneModel cellphoneModel) { try { if (cellphoneModel == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Data is null.")); } if (!ModelState.IsValid) { Errors errors = ErrorsHelper.GetErrors(ModelState); return(Request.CreateResponse(HttpStatusCode.BadRequest, errors)); } CellphoneModel addedCellphone = cellphoneRepository.AddCellphone(cellphoneModel); return(Request.CreateResponse(HttpStatusCode.Created, addedCellphone)); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); return(Request.CreateResponse(HttpStatusCode.InternalServerError, errors)); } }
public CellphoneModel UpdateCellphone(CellphoneModel cellphoneModel) { var resultSP = DB.UpdateCellphone(cellphoneModel.beforeCellphone).Select(beforeCellphone2 => new CellphoneModel { beforeCellphone = beforeCellphone2 }); if (GlobalVariable.queryType == 0) { BeforeCellphone beforeCellphone = DB.BeforeCellphones.Where(c => c.beforeCellphone1.Equals(cellphoneModel.beforeCellphone)).SingleOrDefault(); if (beforeCellphone == null) { return(null); } beforeCellphone.beforeCellphone1 = cellphoneModel.beforeCellphone; DB.SaveChanges(); return(GetOneBeforeCellphone(beforeCellphone.beforeCellphone1)); } else { return(resultSP.SingleOrDefault()); } }
public CellphoneModel AddCellphone(CellphoneModel cellphoneModel) { var resultSP = DB.AddCellphone(cellphoneModel.beforeCellphone).Select(beforeCellphone2 => new CellphoneModel { beforeCellphone = beforeCellphone2 }); if (GlobalVariable.queryType == 0) { BeforeCellphone beforeCellphone = new BeforeCellphone { beforeCellphone1 = cellphoneModel.beforeCellphone }; DB.BeforeCellphones.Add(beforeCellphone); DB.SaveChanges(); return(GetOneBeforeCellphone(beforeCellphone.beforeCellphone1)); } else { return(resultSP.SingleOrDefault()); } }
public HttpResponseMessage UpdateCellphone(string beforeCellphone, CellphoneModel cellphoneModel) { try { if (cellphoneModel == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Data is null.")); } if (!ModelState.IsValid) { Errors errors = ErrorsHelper.GetErrors(ModelState); return(Request.CreateResponse(HttpStatusCode.BadRequest, errors)); } cellphoneModel.beforeCellphone = beforeCellphone; CellphoneModel updatedCellphone = cellphoneRepository.UpdateCellphone(cellphoneModel); return(Request.CreateResponse(HttpStatusCode.OK, updatedCellphone)); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); return(Request.CreateResponse(HttpStatusCode.InternalServerError, errors)); } }
static public OleDbCommand UpdateCellphone(CellphoneModel cellphoneModel) { return(CreateOleDbCommand(cellphoneModel, queryCellphonesUpdate)); }
static public OleDbCommand AddCellphone(CellphoneModel cellphoneModel) { return(CreateOleDbCommand(cellphoneModel, queryCellphonesPost)); }