Exemplo n.º 1
0
        public bool CreateContact(Contact contactToCreate)
        {
            // Validation logic
            if (!ValidateContact(contactToCreate))
            {
                return(false);
            }

            // Database logic
            try
            {
                _repository.CreateContact(contactToCreate);
            }
            catch
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 2
0
        public ActionResult Create([Bind(Exclude = "Id")] Contact contactToCreate)
        {
            // Validation logic
            ValidateContact(contactToCreate);
            if (!ModelState.IsValid)
            {
                return(View());
            }

            // Database logic
            try
            {
                _repository.CreateContact(contactToCreate);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }