// 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")); }
public void CreateConfiguration(ArtooConfiguration configuration) { var existingConfiguration = _appDbContext.ArtooConfigurations.FirstOrDefault(p => p.Name == configuration.Name); if (existingConfiguration == null) { configuration.DateRegister = DateTime.Now; _appDbContext.ArtooConfigurations.Add(configuration); _appDbContext.SaveChanges(); } }
public bool GetConfigurationStatusByName(string name) { ArtooConfiguration config = _appDbContext.ArtooConfigurations.FirstOrDefault(p => p.Name == name); if (config == null) { return(false); } else { return(config.Status); } }
public void UpdateCofigurationByName(ArtooConfiguration configuration) { var existing = _appDbContext.ArtooConfigurations.SingleOrDefault(x => x.Name == configuration.Name); if (existing != null) { existing.Description = configuration.Description; existing.Scope = configuration.Scope; existing.Status = configuration.Status; _appDbContext.ArtooConfigurations.Update(existing); _appDbContext.SaveChanges(); } else { CreateConfiguration(configuration); } }