Beispiel #1
0
        public ActionResult Contact(SendEmailViewModel vm)
        {
            User user = new User();

            user.FirstName   = "Fred";
            user.LastName    = "Fred";
            user.PhoneNumber = "09014671017";
            user.Email       = "*****@*****.**";

            SendEmailViewModel sendEmailViewModel;

            sendEmailViewModel = new SendEmailViewModel();
            sendEmailViewModel.LoggedInUser = user;
            if (ModelState.IsValid)
            {
                //User user = new User();
                //user.FirstName = vm.FirstName;
                //user.LastName = vm.LastName;
                //user.Email = vm.Email;
                //user.PhoneNumber = vm.PhoneNumber;
                //if (user.Roleid == null)
                //{
                //    user.Roleid = 2;
                //}

                Message message = new Message();
                //   message.userId =
                message.FirstName   = vm.FirstName;
                message.LastName    = vm.LastName;
                message.Message1    = vm.Message;
                message.PhoneNumber = vm.PhoneNumber;
                message.Email       = vm.Email;
                message.DateSent    = DateTime.Now;
                try
                {
                    messageRepo.addMessage(message);
                    //  EmailCode.UserSendEmail(user, vm.Message);
                    ViewBag.Status = "Done!";


                    return(View(sendEmailViewModel));
                }
                catch (Exception e)
                {
                    ViewBag.Status = e.Message.ToString();
                    return(View(sendEmailViewModel));
                }
            }
            return(View(sendEmailViewModel));
        }
Beispiel #2
0
        private static void SaveRequestToDb(Message message)
        {
            MessageRepo messageRepo = new MessageRepo();

            messageRepo.addMessage(message);
        }