public async Task <bool> DockShuttle(IShuttle shuttle) { var dbShuttle = ConvertToShuttle(shuttle); dbShuttle.IsDocked = true; return(await _dockRepository.Dock(dbShuttle)); }
internal void DockShuttle(IShuttle shuttle, Action <CommandResult> onSuccess, Action <CommandResult> onFail) { var(iValid, failureCode) = _dockingRules.Validate(this); if (!iValid) { onFail(new CommandResult { IsSuccess = false, Message = failureCode, ShuttleName = $"{shuttle.Name}(id:{shuttle.Id})" }); return; } Shuttles.Add(shuttle); onSuccess(new CommandResult { IsSuccess = true, ShuttleName = $"{shuttle.Name}(id:{shuttle.Id})" }); }
private SpaceStation.Models.Shuttle ConvertToShuttle(IShuttle shuttle) { var standardDimension = _dimensionRepository.GetDimensions().FirstOrDefault(x => x.Type == "Shuttle"); if (standardDimension != null) { return new Models.Shuttle { ShuttleId = shuttle.ShuttleId, DimensionId = standardDimension.DimensionId, IsDocked = shuttle.IsDocked } } ; return(null); } }
public bool CheckSpecifications(IShuttle shuttle) { return(IsValidSpec(shuttle.Dimensions)); }
/// <summary> /// Initializes a new instance of the <see cref="DockingRule"/> class. /// </summary> /// <param name="shuttle">The shuttle.</param> public DockingRule(IShuttle shuttle) { _shuttle = shuttle; _maxShuttlesAllowed = 2; }