Esempio n. 1
0
        public string AddNewTelephoneNumber(TelephoneNumberInfo aTelephoneNumberInfo)
        {
            if (IsNumberAlreadyAvailable(aTelephoneNumberInfo))
            {
                return "Error! Number Already Exist in Database.";
            }

            InsertIntoDatabase(aTelephoneNumberInfo);

            return "Number Success Fully Added.";
        }
Esempio n. 2
0
        private void InsertIntoDatabase(TelephoneNumberInfo aTelephoneNumberInfo)
        {
            string nonQuery = "INSERT INTO allphoneinfo (`PhoneNumber`," +
                              " `ServiceStatus`, `ConnectionTypeID`, `Remarks`)" +
                              " VALUES (@PhoneNumber," +
                              " @ServiceStatus, @ConnectionTypeID, @Remarks);";

            Hashtable aHashtable = new Hashtable()
            {
                {"PhoneNumber", aTelephoneNumberInfo.PhoneNumber},
                {"ServiceStatus", "Terminated"},
                {"ConnectionTypeID", aTelephoneNumberInfo.ConnectionTypeID},
                {"Remarks","New Phone"},

            };
            aGateway.Insert(nonQuery, aHashtable);
        }
Esempio n. 3
0
        private bool IsNumberAlreadyAvailable(TelephoneNumberInfo aTelephoneNumberInfo)
        {
            string query = "select * from allphoneinfo where PhoneNumber=@PhoneNumber;";
            Hashtable aHastable = new Hashtable()
            {
                {"PhoneNumber", aTelephoneNumberInfo.PhoneNumber}
            };

            if (aGateway.Select(query, aHastable).Tables[0].Rows.Count == 0)
            {
                return false;
            }

            return true;
        }
        public ActionResult SubmitNewTelephoneNumber(TelephoneNumberInfo aTelephoneNumberInfo)
        {
            if (aTelephoneNumberInfo.ConnectionTypeID.Trim().Length == 0
                || aTelephoneNumberInfo.PhoneNumber.Trim().Length == 0)
            {
                ViewData["Message"] = "Error! Fill All Fields";
                return View("AddNewTelephoneNumber");
            }

            TelephoneNumber aNumber = new TelephoneNumber();
            string message = aNumber.AddNewTelephoneNumber(aTelephoneNumberInfo);
            ViewData["Message"] = message;
            return View("AddNewTelephoneNumber");
        }