public ActionResult Save(int id, SystemEmailDto model)
        {
            // create view bag first for the vendors
            populateSystemEmailViewBag();
            if (!ModelState.IsValid)
            {
                var errors = ModelState.Values.SelectMany(e => e.Errors.Select(x => x.ErrorMessage));
                ModelState.AddModelError("", string.Join("<br/>", errors));
                return(View("create", model));
            }

            if (_systemEmailsService.IsEmailExist(id, model.EmailAddress))
            {
                if (id <= 0)
                {
                    ModelState.AddModelError("", "Email address already exists");
                    return(View("create", model));
                }
                else
                {
                    ModelState.AddModelError("", "Email address already exists");
                    return(View("edit", model));
                }
            }

            // save the message template
            model.ModifiedBy = User.Identity.Name;
            if (id == 0)
            {
                model = _systemEmailsService.CreateSystemEmail(model);
            }
            else
            {
                model = _systemEmailsService.UpdateSystemEmail(model);
            }

            TempData["Message"] = "Changes have been successfully saved!";
            return(RedirectToAction("edit", new { id = model.Id }));
        }