Ejemplo n.º 1
0
        public SafeAccountChartListViewModel UpdateSafeAccountChart(SafeAccountChartListViewModel model)
        {
            var entityCollection = this._safeAccountChartsRepository.Get(null).Where(x => x.SafeId == model.safeId);

            if (entityCollection.Count() > 0)
            {
                foreach (var item in entityCollection)
                {
                    this._safeAccountChartsRepository.Delete(item);
                }
                this._unitOfWork.Commit();
            }

            if (model.List?.Count > 0)
            {
                foreach (var item in model.List)
                {
                    SafeAccountChart newEntity = new SafeAccountChart
                    {
                        SafeId         = model.safeId,
                        AccountChartId = item.Value
                    };
                    this._safeAccountChartsRepository.Add(newEntity);
                }
                this._unitOfWork.Commit();
            }

            return(model);
        }
Ejemplo n.º 2
0
        public SafeAccountChartListViewModel GetSafeAccountChart(long safeId)
        {
            var lang             = this._languageService.CurrentLanguage;
            var entityCollection = this._safeAccountChartsRepository.Get(null).Where(x => x.SafeId == safeId).ToList();

            SafeAccountChartListViewModel result = new SafeAccountChartListViewModel
            {
                safeId = safeId,
                List   = new List <NmaeValueViewModel>()
            };

            foreach (var item in entityCollection)
            {
                result.List.Add(new NmaeValueViewModel
                {
                    Value = item.AccountChartId,
                    Name  = item.AccountChart.ChildTranslatedAccountCharts.FirstOrDefault(x => x.Language == lang).Name
                });
            }
            return(result);
        }