public ActionResult Create(ContactMessage contactMessage) { if (!ModelState.IsValid) { return(RedirectToAction("Index", "Contact")); } try { _repository.Add(contactMessage); } catch (Exception ex) { Debug.WriteLine(ex.Message); return(RedirectToAction("Index", "Contact")); } return(RedirectToAction("Index", "Contact")); }
public void AddContactMessage(string userId, string fullName, string email, string description) { Guid userIdGuid = Guid.Empty; if (!Guid.TryParse(userId, out userIdGuid)) { throw new Exception("Invalid Guid Format"); } var client = clientRepository.GetClientByUserId(userIdGuid); if (client == null) { throw new EntityNotFoundException(userIdGuid); } contactMessageRepository.Add(new ContactMessage() { Id = Guid.NewGuid(), FullName = fullName, Email = email, MessageText = description, Client = client }); }
public void Add(ContactMessageViewModel message) { _contactMessageRepository.Add(ToContactMessage(message)); }