Beispiel #1
0
        public ActionResult Create(ContactFormViewModel model)
        {
            try
            {
                // TODO: Add insert logic here
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                var ContactForm = _mapper.Map <ContactForm>(model);
                var isSuccess   = _repo.Create(ContactForm);
                if (!isSuccess)
                {
                    ModelState.AddModelError("", "Something Went Wrong!");
                    return(View(model));
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                ModelState.AddModelError("", "Something Went Wrong!");
                return(View(model));
            }
        }
        public ActionResult Create(ContactFormModel contactForm)
        {
            if (ModelState.IsValid)
            {
                _contactRepository.Create(contactForm);
                //var message = _emailService.CreateMailMessage(contactForm);
                //_emailService.SendEmail(message);
                return(RedirectToAction("Index"));
            }

            return(View(contactForm));
        }
 public int Create(ContactForm contactForm)
 {
     return(_repo.Create(contactForm));
 }