// GET: /<controller>/ public IActionResult Index() { IEnumerable <EmailRule> emailRules = _emailRuleRepository.GetEmailRuleIncludePassion(); EmailRuleListViewModel emailRuleListVM = new EmailRuleListViewModel(); List <EmailRuleViewModel> emailRulesVM = new List <EmailRuleViewModel>(); foreach (var item in emailRules) { IEnumerable <EmailRuleDetail> emailRuleDetail = _emailRuleRepository.GetEmailRuleDetailByEmailRuleId(item.EmailRuleId); List <int> emailIds = emailRuleDetail.Select(x => x.EmailId).ToList(); IEnumerable <Email> emails = _emailRepository.GetEmailByIdList(emailIds); EmailRuleViewModel emailRuleVM = new EmailRuleViewModel() { EmailRuleId = item.EmailRuleId, Result = item.Result, OrderType = item.OrderType, EmailList = emails, PassionBrand = item.PassionBrand }; emailRulesVM.Add(emailRuleVM); } ArtooConfiguration config = _configurationRepository.GetConfigurationByName(ConfigurationEnum.sendAllMail.ToString()); bool status = config == null ? false : config.Status; ViewBag.Current = "EmailRuleList"; return(View(new EmailRuleListViewModel { EmailRules = emailRulesVM, SendAllMail = status })); }
public IActionResult Index(EmailRuleListViewModel emailRuleListVM) { ArtooConfiguration configuration = new ArtooConfiguration { Name = ConfigurationEnum.sendAllMail.ToString(), Status = emailRuleListVM.SendAllMail }; _configurationRepository.UpdateCofigurationByName(configuration); return(RedirectToAction("Index")); }