示例#1
0
        public void GetFullCostSetting(ref List <Entities.CostSetting> listCostSetting)
        {
            RoleService          roleService = new RoleService();
            UserService          userService = new UserService();
            List <Entities.Item> AllPlace    = placeService.AllPlace();

            foreach (Entities.CostSetting cost in listCostSetting)
            {
                // Lấy thông tin tên địa lý.
                if (cost.CityId > 0)
                {
                    cost.CityName = AllPlace.Where(x => x.Id == cost.CityId).FirstOrDefault().Text;
                }

                if (cost.DistrictId > 0)
                {
                    cost.DistrictName = AllPlace.Where(x => x.Id == cost.DistrictId).FirstOrDefault().Text;
                }
                if (cost.WardId > 0)
                {
                    cost.WardName = AllPlace.Where(x => x.Id == cost.WardId).FirstOrDefault().Text;
                }

                // Lấy thông tin tên vùng.
                if (cost.RegionId > 0)
                {
                    cost.RegionName = regionService.GetItem(cost.RegionId).Text;
                }

                // Lấy kiểu nhà
                if (cost.ProductType > 0)
                {
                    cost.ProductTypeName = productService.ProductType(cost.ProductType).Text;
                }

                // Lấy tên nhóm.
                if (cost.UserRole > 0)
                {
                    cost.GroupName = roleService.GetItem(cost.UserRole).Text;
                }

                // Lấy tên người dùng.
                if (!string.IsNullOrEmpty(cost.UserIds))
                {
                    string[]   arr        = cost.UserIds.Split(',');
                    List <int> lstUserIds = arr.Select(Int32.Parse).ToList();
                    var        listUser   = userService.ListItem(lstUserIds);
                    cost.ListUserName = listUser.Select(x => x.Text).ToList();
                }
                else
                {
                    cost.ListUserName = new List <string>();
                }
            }
        }