/// <summary> /// Converts MissionRequestAzure to MissionRequest.. /// </summary> /// <param name="azureModel">The azure model.</param> /// <returns>MissionRequest.</returns> public static MissionRequest FromAzureModel(this MissionRequestAzure azureModel) { if (azureModel == null) { return(null); } var domainModel = new MissionRequest(); azureModel.CopyTo(domainModel); MissionRequestStatus status; if (Enum.TryParse(azureModel.Status, out status)) { domainModel.Status = status; } domainModel.StarsCount = (byte?)azureModel.StarsCount; domainModel.Proof = new MissionProof { ImageUrls = azureModel.ProofImageUrls?.SplitStringByDelimiter(), CreatedText = azureModel.CreatedText, Coordinates = azureModel.ProofCoordinates?.SplitStringByDelimiter(CommonConstants.Delimiter)?.Select(coord => coord.ConvertToGeoCoordinate()).ToList(), TimeElapsed = azureModel.TimeElapsed, NumberOfTries = (ushort?)azureModel.NumberOfTries }; return(domainModel); }
/// <summary> /// To the azure model. /// </summary> /// <param name="missionRequest">The mission request.</param> /// <returns>MissionRequestAzure</returns> public static MissionRequestAzure ToAzureModel(this MissionRequest missionRequest) { var azureModel = new MissionRequestAzure(); missionRequest.CopyTo(azureModel); azureModel.StarsCount = missionRequest.StarsCount; azureModel.Status = missionRequest.Status.ToString(); //set proofs azureModel.ProofImageUrls = missionRequest.Proof.ImageUrls?.JoinToString(); azureModel.ProofCoordinates = missionRequest.Proof.Coordinates?.Select(coord => coord.ConvertToAzureCoordinate()) .JoinToString(CommonConstants.Delimiter); azureModel.CreatedText = missionRequest.Proof.CreatedText; azureModel.TimeElapsed = missionRequest.Proof.TimeElapsed; azureModel.NumberOfTries = missionRequest.Proof.NumberOfTries; return(azureModel); }