public Satellite BuildSatellite(AddSatelliteObject addSatelliteObject) { var satellite = (Satellite)Mapper.Map(addSatelliteObject, addSatelliteObject.GetType(), typeof(Satellite)); return(satellite); }
public async Task <EntityResponse <SatelliteMessageDto> > Handle(AddSingleSatelliteRequest request, CancellationToken cancellationToken) { var satellite = SateliteMapper.BuildSingleSatellite(request); var completionStatus = satellite.Validate(); var satelliteObject = new AddSatelliteObject { Distance = request.Satelite.Distance, Name = request.SatelliteName, Message = request.Satelite.Message }; var cacheList = request.Cache.Get <List <AddSatelliteObject> >("satelliteList"); if (cacheList == null) { request.Cache.Set("satelliteList", new List <AddSatelliteObject> { satelliteObject }); } else { cacheList.Add(satelliteObject); } var satelliteMessage = new SatelliteMessageDto(); if (completionStatus.IsSuccessful) { satelliteMessage = UnitOfWork.SatelliteRepository.FindInformation(cacheList); } else { completionStatus.AddValidationMessage("The names of the satellites are required "); } if (!string.IsNullOrEmpty(satelliteMessage.Message) && satelliteMessage.Position != null) { cacheList.Clear(); } var response = new EntityResponse <SatelliteMessageDto> { Entity = satelliteMessage, Status = completionStatus }; return(response); }