public ActionResult Create(ClientSetting clientSetting)
        {
            if (ModelState.IsValid)
            {
                db.ClientSettings.Add(clientSetting);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.ClientId = new SelectList(db.Clients, "Id", "Name", clientSetting.ClientId);
            return View(clientSetting);
        }
        private SendGridMessage CreateSendGridMessage(string emailTo, string emailFrom, string name, string message, List<UploadedFile> files, ClientSetting clientSettings, bool autoReply = false)
        {
            // Create the email object first, then add the properties.
            SendGridMessage myMessage = new SendGridMessage();

            myMessage.AddTo(emailTo);

            myMessage.From = new MailAddress(emailFrom, name);

            myMessage.Subject = autoReply ? clientSettings.AutoReplySubjectLine : clientSettings.SubjectLine;

            myMessage.Html = message;

            if (clientSettings.EnableFileUpload && !autoReply)
            {
                foreach (var file in files)
                {
                    myMessage.AddAttachment(new MemoryStream(file.FileBytes), file.FileName);
                }
            }

            return myMessage;
            
        }
 public ActionResult Edit(ClientSetting clientSetting)
 {
     if (ModelState.IsValid)
     {
         db.Entry(clientSetting).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.ClientId = new SelectList(db.Clients, "Id", "Name", clientSetting.ClientId);
     return View(clientSetting);
 }