public ActionResult EditConfirmation(EmailTemplateViewModel emailTemplateViewModel)
 {
     if (ModelState.IsValid)
     {
         var type = Request.QueryString["type"];
         return RedirectToAction("Index", new { type = type });
     }
     else
     {
         return View(emailTemplateViewModel);
     }
 }
 public ActionResult CreateOrUpdate(EmailTemplateViewModel emailTemplateViewModel)
 {
     var type = Request.QueryString["type"];
     CreateOrUpdateEmailTemplate(emailTemplateViewModel, type);
     return RedirectToAction("Index", new { type = type });
 }
        private void CreateOrUpdateEmailTemplate(EmailTemplateViewModel emailTemplateViewModel, string type)
        {
            if (emailTemplateViewModel.Id == 0)
                Create(emailTemplateViewModel, type);

            else
                Update(emailTemplateViewModel);
        }
 private void Update(EmailTemplateViewModel emailTemplateViewModel)
 {
     var emailTemplateInfo = _emailTemplateService.GetById(emailTemplateViewModel.Id);
     emailTemplateInfo.Subject = emailTemplateViewModel.Subject;
     emailTemplateInfo.Body = emailTemplateViewModel.Body;
     _emailTemplateService.Edit(emailTemplateInfo);
 }
        private string Create(EmailTemplateViewModel emailTemplateViewModel, string type)
        {
            string selectedValue;
            short? branchId = null;
            int? campaignId = null;

            selectedValue = Request.Form["listItemsDD"].ToString();
            if (type == Constant.Branch)
                branchId = short.Parse(selectedValue);
            else
                campaignId = int.Parse(selectedValue);
            _emailTemplateService.Create(campaignId, branchId,
            emailTemplateViewModel.Subject, emailTemplateViewModel.Body);
            return selectedValue;
        }