public int DeleteTelephone(string beforeTelephone1)
        {
            var resultSP = DB.DeleteTelephone(beforeTelephone1);

            if (GlobalVariable.queryType == 0)
            {
                BeforeTelephone beforeTelephone = DB.BeforeTelephones.Where(t => t.beforeTelephone1.Equals(beforeTelephone1)).SingleOrDefault();
                DB.BeforeTelephones.Attach(beforeTelephone);
                if (beforeTelephone == null)
                {
                    return(0);
                }
                DB.BeforeTelephones.Remove(beforeTelephone);
                DB.SaveChanges();
                return(1);
            }
            else
            {
                return(resultSP);
            }
        }
        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 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());
            }
        }