public ActionResult Contact(Contact aContact)
 {
     if (contactManager.Add(aContact))
     {
         return(RedirectToAction("HomePage", new { success = "true" }));
     }
     else
     {
         return(RedirectToAction("HomePage", new { success = "false" }));
     }
 }
Пример #2
0
 internal ContactDTO AddNewContact(ContactDTO Model)
 {
     try
     {
         return(contactManager.Add(Model));
     }
     catch (Exception ex)
     {
         var loger = LogManager.GetLogger("*");
         loger.Log(LogLevel.Error, ex.Message);
         return(null);
     }
 }
        public ActionResult Contact([Bind(Include = "Email,PhoneNo,Message")] ContactViewModel contactViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    ContactModel contactm = Mapper.Map <ContactModel>(contactViewModel);

                    _contactManager.Add(contactm);
                    TempData["msg"] = "Message has been send successfully";
                    return(RedirectToAction("Contact"));
                }
                return(View());
            }
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Home", "Contact")));
            }
        }
        public ActionResult Create(ContactDto contactDto)
        {
            bool result = false;

            if (ModelState.IsValid)
            {
                result = _iContactManager.Add(contactDto);
            }
            else
            {
                result = false;
            }

            if (result)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(contactDto));
            }
        }
 public Contact Post(Contact contact)
 {
     contactManager = new ContactManager(ModelFactory <ContactModel> .GetContext());
     return(contactManager.Add(contact));
 }