Ejemplo n.º 1
0
        public async Task <bool> Execute(CreateGroupStationInputModel groupStationInput)
        {
            var group = new GroupStation(groupStationInput.Name, groupStationInput.CapacityAmps);

            Parallel.ForEach(groupStationInput.ChargeStations, chargeStation =>
            {
                var newChargStation = new ChargeStation(chargeStation.Name);

                var newConnectorList = CreateConnectors(chargeStation, newChargStation);

                newChargStation.Connectors.AddRange(newConnectorList);

                group.AddChargeStation(newChargStation);
            });

            if (group.IsCapacityOfGroup() > group.CapacityAmps)
            {
                var numberOfExcessConnector = group.IsCapacityOfGroup() - group.CapacityAmps;

                HandlerMessage = $"The capactiy of Connector was excessed. You may remove {numberOfExcessConnector} of Connectors";

                return(false);
            }

            await _groupRepository.Add(group);

            HandlerMessage = "Group has been added";

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 执行
        /// </summary>
        /// <returns>返回执行结果</returns>
        public override object Do()
        {
            Group g = new Group();

            g.CheckPhysicsTable();

            GroupEmp ge = new GroupEmp();

            ge.CheckPhysicsTable();

            GroupStation gs = new GroupStation();

            gs.CheckPhysicsTable();

            UserMenu um = new UserMenu();

            um.CheckPhysicsTable();

            ////删除数据.
            //EmpMenus mymes = new EmpMenus();
            //mymes.GetNewEntity.CheckPhysicsTable();
            //mymes.ClearTable();

            //EmpApps empApps = new EmpApps();
            //empApps.GetNewEntity.CheckPhysicsTable();
            //empApps.ClearTable();

            ////查询出来菜单.
            //Menus menus = new Menus();
            //menus.RetrieveAllFromDBSource();

            ////查询出来所有的应用系统.
            //Apps apps = new Apps();
            //apps.RetrieveAllFromDBSource();

            ////查询出来人员.
            //Emps emps = new Emps();
            //emps.RetrieveAllFromDBSource();

            return("所有的成员都被初始化成功.");
        }
Ejemplo n.º 3
0
 public async Task Update(string id, GroupStation groupIn)
 {
     await _groupCollection.ReplaceOneAsync <GroupStation>(g => g.Id == id, groupIn);
 }
Ejemplo n.º 4
0
 public async Task Delete(GroupStation group)
 {
     await _groupCollection.DeleteOneAsync(order => order.Id == group.Id);
 }
Ejemplo n.º 5
0
 public async Task Add(GroupStation group) => await _groupCollection.InsertOneAsync(group);