Ejemplo n.º 1
0
        public ActionResult CreateNewContact(Contact newContact)
        {
            DbConnection conn = new DbConnection();

            conn.SqlCommand.Connection.Open();

            ContactLogic logic     = new ContactLogic();
            int          contactID = -1;

            try
            {
                contactID     = logic.CreateNewContact(conn, newContact.Name, newContact.Surname, newContact.Phone, newContact.Email);
                newContact.Id = contactID;
            }
            catch (Exception e)
            {
                ViewData["Message"] = ErrorMessages.CreateNewContact;

                return(View("Messages"));
            }
            finally
            {
                conn.SqlCommand.Connection.Close();
            }

            return(View("EditContact", newContact));
        }
Ejemplo n.º 2
0
        //[Route("CreateNewContact")]
        public async Task <IActionResult> CreateContact(Contact contact)
        {
            var data = await _context.CreateNewContact(contact.FirstName, contact.LastName, contact.Address, contact.TelephoneNumber);

            if (data == false)
            {
                return(BadRequest());
            }
            return(Ok());
            //return Ok("A new contact was Successfully created.");
        }
Ejemplo n.º 3
0
        public async Task <Boolean> AddContact(string firstname, string lastname, string address, string telephonenumber)
        {
            bool result = await contactLogic.CreateNewContact(firstname, lastname, address, telephonenumber);

            return(result);
        }