Beispiel #1
0
        // Creates a contact
        public int create(String forename, String surname, String position, String phoneNumber)
        {
            // Establishes contact model
            ContactModel contactModel = new ContactModel();

            // Holds new contact
            Contact newContact = new Contact();

            // Stored details for the contact
            newContact.Forename    = forename;
            newContact.Surname     = surname;
            newContact.Position    = position;
            newContact.PhoneNumber = phoneNumber;

            // Acquires contactID
            int contactID = contactModel.CreateContact(newContact);

            // Returns contactID
            return(contactID);
        }
        public IHttpActionResult CreateContact([FromBody] ContactModel _Contact)
        {
            try
            {
                if (_Contact == null)
                {
                    return(BadRequest());
                }

                if (_ContactModel.CreateContact(_Contact) == "Saved_Successfully")
                {
                    return(Ok(true));
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
            return(Ok(false));
        }