public IHttpActionResult Save(EditCurrencyData data) { var newCurrency = string.IsNullOrEmpty(data.OldCode); VerifyPermission(newCurrency ? Permissions.Create : Permissions.Update, Modules.CurrencyManager); var result = newCurrency ? _currencyCommands.Add(data) : _currencyCommands.Save(data); if (!result.IsSuccess) { return(Ok(new { Result = "false", Data = "app:common." + result.Message })); } return(Ok(new { Result = "success", Data = "app:currencies." + result.Message })); }
private void AddCurrencies(string[] codes) { var regionInfoGroups = CultureInfo .GetCultures(CultureTypes.AllCultures) .Where(c => !c.IsNeutralCulture) .Select(culture => { const int invariantClutureId = 127; if (culture.LCID == invariantClutureId) { return(null); } return(new RegionInfo(culture.LCID)); }) .Where(ri => ri != null) .GroupBy(ri => ri.ISOCurrencySymbol) .Where(x => codes.Contains(x.Key)) .ToArray(); foreach (var group in regionInfoGroups) { var code = group.Key; if (_brandRepository.Currencies.Any(x => x.Code == code)) { continue; } _currencyCommands.Add(new EditCurrencyData { //AFTREGO-3538 Change Chinese Currency to "RMB" Code = code.Equals("CNY") ? "RMB" : code, Name = group.First().CurrencyEnglishName, Remarks = "Created automatically while seeding database at first start" }); _brandRepository.SaveChanges(); } }