コード例 #1
0
        public async Task <IActionResult> UpdateGroup(UpdateGroupStationInputModel group, string idGroup)
        {
            var commandHandler = new UpdateGroupSationCommandHandler(_groupRepository);
            var result         = await commandHandler.Execute(group, idGroup);

            if (result)
            {
                return(Ok(commandHandler.HandlerMessage));
            }

            return(NoContent());
        }
コード例 #2
0
        public async Task <bool> Execute(UpdateGroupStationInputModel groupStationInput, string groupId)
        {
            var group = await _groupRepository.GetGroupById(groupId);

            group.SetName(groupStationInput.Name);
            group.SetCapacityAmps(groupStationInput.CapacityAmps);

            Parallel.ForEach(groupStationInput.ChargeStations, chargeStation =>
            {
                foreach (var connector in chargeStation.Connectors)
                {
                    group.UpdateChargeStation(chargeStation.Name, connector.ChargeStationId, connector.MaxCurrentAmps);
                }
            });

            await _groupRepository.Update(groupId, group);

            HandlerMessage = "the Group has updated";
            return(true);
        }