示例#1
0
        public TelephoneModel UpdateTelephone(TelephoneModel telephoneModel)
        {
            _telephones.ReplaceOne(telephone => telephone.beforeTelephone.Equals(telephoneModel.beforeTelephone), telephoneModel);
            TelephoneModel tmpTelephoneModel = GetOneBeforeTelephone(telephoneModel.beforeTelephone);

            return(tmpTelephoneModel);
        }
示例#2
0
        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);
        }
示例#4
0
        public TelephoneModel UpdateTelephone(TelephoneModel telephoneModel)
        {
            int i = -1;

            using (OleDbCommand command = new OleDbCommand())
            {
                i = ExecuteNonQuery(TelephoneStringsInner.UpdateTelephone(telephoneModel));
            }
            return(GetOneBeforeTelephone(telephoneModel.beforeTelephone));
        }
示例#5
0
 static public MySqlCommand UpdateTelephone(TelephoneModel telephoneModel)
 {
     if (GlobalVariable.queryType == 0)
     {
         return(CreateSqlCommand(telephoneModel, queryTelephonesUpdate));
     }
     else
     {
         return(CreateSqlCommand(telephoneModel, procedureTelephonesUpdate));
     }
 }
示例#6
0
        public TelephoneModel AddTelephone(TelephoneModel telephoneModel)
        {
            if (GetOneBeforeTelephone(telephoneModel.beforeTelephone) == null)
            {
                _telephones.InsertOne(telephoneModel);
            }

            TelephoneModel tmpTelephoneModel = GetOneBeforeTelephone(telephoneModel.beforeTelephone);

            return(tmpTelephoneModel);
        }
示例#7
0
 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));
     }
 }
示例#8
0
        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);
        }
示例#9
0
        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);
        }
示例#10
0
 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);
     }
 }
示例#11
0
        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);
        }
示例#12
0
        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());
            }
        }
示例#15
0
        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));
            }
        }
示例#16
0
        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));
            }
        }
示例#17
0
 static public OleDbCommand AddTelephone(TelephoneModel telephoneModel)
 {
     return(CreateOleDbCommand(telephoneModel, queryTelephonesPost));
 }
示例#18
0
 static public OleDbCommand UpdateTelephone(TelephoneModel telephoneModel)
 {
     return(CreateOleDbCommand(telephoneModel, queryTelephonesUpdate));
 }