示例#1
0
        public ActionResult DeleteConfirmed(int id)
        {
            try
            {
                // TODO: Add delete logic here
                //Movie movie = db.Movies.Find(id);
                string query = "DELETE FROM My_Gmail_Contacts WHERE Contact_ID = " + id + ";";
                My_Contacts.ExecuteCommand(query);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
示例#2
0
        public ActionResult Edit(int id, [Bind(Include = "Contact_ID,Name,Email,DOB")] My_Contacts contact)
        {
            try
            {
                // TODO: Add update logic here
                if (ModelState.IsValid)
                {
                    string query = "UPDATE My_Gmail_Contacts SET Name = '" + contact.Name + "', Email= '" + contact.Email + "', DOB = '" + contact.DOB + "' WHERE Contact_ID = " + id + ";";
                    My_Contacts.ExecuteCommand(query);

                    return(RedirectToAction("Index"));
                }
            }
            catch
            {
                return(View(contact));
            }
            return(View(id));
        }
示例#3
0
        public ActionResult Create(My_Contacts My_Contacts)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //string query = "INSERT INTO My_Gmail_Contacts(Name,DOB,Email) VALUES('" + My_Contacts.Name + "','" + My_Contacts.DOB + "','" + My_Contacts.Email + "')";
                    Dictionary <string, object> data = new Dictionary <string, object>();
                    data.Add("Name", My_Contacts.Name);
                    data.Add("DOB", My_Contacts.DOB);
                    data.Add("Email", My_Contacts.Email);

                    My_Contacts.ExecuteCommand("Add_Contact", data);
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }