Exemple #1
0
        public AjaxResult EditMoneys(IEnumerable <CurrencyModel> money)
        {
            List <CurrencyModel> moneyToUpdate = new List <CurrencyModel>();
            List <CurrencyModel> errors        = new List <CurrencyModel>();

            foreach (var m in money)
            {
                if (ModelState.IsValid)
                {
                    moneyToUpdate.Add(m);
                }
                else
                {
                    errors.Add(m);
                }
            }

            if (moneyToUpdate.Count > 0)
            {
                _stockManagementService.UpdateCurrencies(moneyToUpdate);
            }

            if (errors.Count > 0)
            {
                return(new AjaxResult(AjaxResultState.Error, errors));
            }

            return(new AjaxResult(AjaxResultState.OK));
        }