protected override async Task <IResponseContainer> GetResultAsync(UpdateConnectorRequest request) { IResponseContainer result = new ResponseContainer(); var connector = await connectorRepository.GetByChargeStationIdAndLineNoAsync(request.ChargeStationId, request.LineNo); if (connector is null) { result.AddErrorMessage($"Connector with ID={request.ChargeStationId} is not found."); return(result); } var updateResponseContainer = await connector.UpdateMaxCurrentInAmps(request.MaxCurrentInAmps, groupRepository); result.JoinWith(updateResponseContainer); if (result.IsSuccess) { var previousValue = connector.MaxCurrentInAmps; await connectorRepository.UpdateAsync(connector); Log.Info($"Connector with ID={connector.GetNumericId()} is updated with new value {request.MaxCurrentInAmps}, previous value was {previousValue}."); } else { Log.Error(result.Messages); } return(result); }
public Task <IResponseContainer> IsSatisfiedBy(Group entity) { var result = new ResponseContainer(); if (capacityInAmps <= 0) { result.AddErrorMessage($"Capacity has to be greater than 0."); } var nameSpecificationResponseContainer = new NameSpecification().IsSatisfiedBy(name).Result; result.JoinWith(nameSpecificationResponseContainer); return(Task.FromResult(result.AsInterface())); }
protected override async Task <IResponseContainer> GetResultAsync(DeleteChargeStationRequest request) { var result = new ResponseContainer(); var chargeStation = await chargeStationRepository.GetAsync(request.Id); if (chargeStation is not null) { await chargeStationRepository.DeleteAsync(chargeStation.Id); Log.Info($"Charge station ID={chargeStation.Id} has been deleted."); } else { var message = $"Charge station with ID={request.Id} is not found."; result.AddErrorMessage(message); Log.Error(message); } return(result); }
protected override async Task <IResponseContainer> GetResultAsync(DeleteGroupRequest request) { var result = new ResponseContainer(); var group = await groupRepository.GetAsync(request.Id); if (group is not null) { await groupRepository.DeleteAsync(group.Id); Log.Info($"Group with ID={group.Id} has been deleted."); } else { var message = $"Group with ID={request.Id} is not found."; result.AddErrorMessage(message); Log.Error(message); } return(result); }
protected override async Task <IResponseContainer> GetResultAsync(DeleteConnectorRequest request) { var result = new ResponseContainer(); var connector = await connectorRepository.GetByChargeStationIdAndLineNoAsync(request.ChargeStationId, request.LineNo); if (connector is not null) { await connectorRepository.DeleteAsync(connector.Id); Log.Info($"Connector {connector} has been deleted."); } else { var message = $"Connector with charge station ID={request.ChargeStationId} and line #{request.LineNo} is not found."; result.AddErrorMessage(message); Log.Error(message); } return(result); }