Example #1
0
        private List <HeatingVentilationSystem> ProcessGroupRoomsBy(Func <AirExchangeRoomResource, string> exp, IList <AirExchangeRoomResource> rooms, int projectId)
        {
            List <HeatingVentilationSystem> heatings = new List <HeatingVentilationSystem>();
            var groupedRooms = rooms.GroupBy(exp).ToList();

            foreach (var items in groupedRooms)
            {
                var t = items.Key;
                HeatingVentilationSystem h = null;
                var heatingInDb            = UnitOfWork.Repository <HeatingVentilationSystem>()
                                             .GetEnumerable(x => x.SystemName.ToUpper().Contains(items.Key.ToUpper()) &&
                                                            x.ProjectId == projectId)
                                             .FirstOrDefault();

                if (heatingInDb == null)
                {
                    HeatingVentilationSystem heating = new HeatingVentilationSystem(CurrentUser.Id);
                    heating.SystemName = items.Key;
                    heating.ProjectId  = projectId;
                    h = heating;
                }
                else
                {
                    h = heatingInDb;
                }
                FillHeating(h, items);

                if (h.Id == 0)
                {
                    UnitOfWork.Repository <HeatingVentilationSystem>().Add(h);
                    heatings.Add(h);
                }
            }
            return(heatings);
        }
Example #2
0
        private void FillHeating(HeatingVentilationSystem heating, IGrouping <string, AirExchangeRoomResource> roomsGroup)
        {
            string roomNames        = "";
            double?fanAirConsuption = 0;

            foreach (var item in roomsGroup)
            {
                roomNames        += item.RoomName + ", ";
                fanAirConsuption += (item.InflowCalc + item.ExhaustCalc);
            }
            heating.FanAirConsumption        = fanAirConsuption;
            heating.AirCoolerCoolingTempFrom = roomsGroup.Select(x => x.TempIn)?.Min();
            heating.RoomName = roomNames.TrimEnd(' ').TrimEnd(',');
        }