public string GetDbOption(string optionCode, out bool existOption) { string value = string.Empty; existOption = false; if (!string.IsNullOrWhiteSpace(optionCode)) { try { OptionItemEntity option = dataService.Select <OptionItemEntity>().FirstOrDefault(x => x.Code == optionCode); if (option != null) { value = option.Value; existOption = true; } } catch (Exception e) { ;//throw; } } return(value); }
private bool ExistDbOption(string optionCode) { bool value = false; if (!string.IsNullOrWhiteSpace(optionCode)) { OptionItemEntity option = dataService.Select <OptionItemEntity>().FirstOrDefault(x => x.Code == optionCode); if (option != null) { value = true; } } return(value); }
public void SetDbOption(string optionCode, string value) { if (!string.IsNullOrWhiteSpace(optionCode)) { OptionItemEntity option = dataService.Select <OptionItemEntity>().FirstOrDefault(x => x.Code == optionCode); if (option == null) { option = dataService.DataBaseContext.OptionItemEntities.Create(); option.Code = optionCode; dataService.DataBaseContext.OptionItemEntities.Add(option); } option.Value = value; dataService.DataBaseContext.SaveChanges(); } }