예제 #1
0
        public CellphoneModel UpdateCellphone(CellphoneModel cellphoneModel)
        {
            _cellphone.ReplaceOne(cellphone => cellphone.beforeCellphone.Equals(cellphoneModel.beforeCellphone), cellphoneModel);
            CellphoneModel tmpCellphoneModel = GetOneBeforeCellphone(cellphoneModel.beforeCellphone);

            return(tmpCellphoneModel);
        }
예제 #2
0
        static private OleDbCommand CreateOleDbCommand(CellphoneModel cellphoneModel, string commandText)
        {
            OleDbCommand command = new OleDbCommand(commandText);

            command.Parameters.AddWithValue("@beforeCellphone", cellphoneModel.beforeCellphone);
            return(command);
        }
예제 #3
0
        public static CellphoneModel ToObject(DataRow reader)
        {
            CellphoneModel cellphoneModel = new CellphoneModel();

            cellphoneModel.beforeCellphone = reader[0].ToString();

            Debug.WriteLine("CellphoneModel:" + cellphoneModel.ToString());
            return(cellphoneModel);
        }
예제 #4
0
        public CellphoneModel UpdateCellphone(CellphoneModel cellphoneModel)
        {
            int i = -1;

            using (OleDbCommand command = new OleDbCommand())
            {
                i = ExecuteNonQuery(CellphoneStringsInner.UpdateCellphone(cellphoneModel));
            }

            return(GetOneBeforeCellphone(cellphoneModel.beforeCellphone));
        }
예제 #5
0
        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));
     }
 }
예제 #7
0
 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);
        }
예제 #12
0
        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());
            }
        }
예제 #15
0
        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));
            }
        }
예제 #16
0
 static public OleDbCommand UpdateCellphone(CellphoneModel cellphoneModel)
 {
     return(CreateOleDbCommand(cellphoneModel, queryCellphonesUpdate));
 }
예제 #17
0
 static public OleDbCommand AddCellphone(CellphoneModel cellphoneModel)
 {
     return(CreateOleDbCommand(cellphoneModel, queryCellphonesPost));
 }