Headshot
- 734 lines in original
- 650 new line of code
dynacon changes post in this group

Analysis
5582- Updating font weight for Odd Pricing Type for DC label
- font-resizer.component.ts
- Labels have styling based on theme as well along with Dynacon.
- CSS file change at 2 places epcot and mgm3
- After 4212 comment Neetu will pick
3440- Display Possession Icons to be Consistent with EDP Scoreboard for Tennis
- I would like to know if it is too much work to implement the possession icon on EDP header for SI brand and EDP header for ON label. (For Betmgm it is already there except ON label).
- Also, do ask devs to consider the impact on my favs section
- Good work by Gayatri
- EDP was last point in story, why has it not been deleted as per what I remember.
5480
- call Pritam
Check deployed version in AIT
- https://sportsadmin.ait.env.works/srvadm/version.xml
- http://sportsadminapi.ait.env.works/srvadm/version.xml
7726
- Sonarqube not passing
- Milestone should be added for MS2
- module-pick-source.service
- event-pick-provider and bet-view
- picksTracking → PickSource.get
- modular service, option panel
- betslip-digital-tracking.service.ts
- option-panel → trackevents
- What is the source here? COMPONENT_BET_TRACKING?
We have tried your approach and here is the commit ID with that for which we found the following issue, in our previous commit we are planning to change switch with if statement and planning to share a new commit with you soon.



Updates:
- 4212 - Neetu should take care. - Waiting CG. Betstation. What is yes no option group data?
- Prachi story, follow up once with CGs.
- 4115
- 4057
- Who has started on the US 5582, 3440, 5480
Demo
- Font weight story
Sportsadmin what I tried
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Security.Principal;
using System.Threading.Tasks;
using Bwin.SportsPosAdmin.Business.DirectoryManager;
using Bwin.SportsPosAdmin.Business.Extensions;
using Bwin.SportsPosAdmin.Common.Logging;
using Bwin.SportsPosAdmin.Data;
using Bwin.SportsPosAdmin.Model.ParticipantImage;
using Bwin.SportsPosAdmin.Model.ParticipantImage.Config;
using Bwin.SportsPosAdmin.Trading.Provider;
using Newtonsoft.Json;
using Bwin.SportsPosAdmin.Common.Exceptions;
using Bwin.SportsPosAdmin.Model.CompetitionLogo;
using System.IO;
using ParticipantImageInfo = Bwin.SportsPosAdmin.Model.ParticipantImage.ParticipantImage;
using Bwin.SportsPosAdmin.Model.Common;
using Bwin.SportsPosAdmin.Data.Model.Modules;
using ParticipantsModel = Bwin.SportsAdmin.Model.V1.ParticipantImage.Participant;
using ImageType = Bwin.SportsPosAdmin.Model.ParticipantImage;
namespace Bwin.SportsPosAdmin.Business.ParticipantImage
{
public sealed class ParticipantImageProvider : IParticipantImageProvider
{
#region Private Properties
private readonly ITradingMasterDataProvider tradingMasterDataProvider;
private readonly IDirectoryManager directoryManager;
private readonly ParticipantImageManagementConfiguration config;
private readonly LogoManagementColorCodesConfiguration colorCodesConfig;
private readonly IMultiLogger logger;
private readonly JsonSerializerSettings jsonSerializerSettings;
private readonly IModuleConfigurationDataProvider moduleConfigurationDataProvider;
private readonly string ImageKey = "data";
private readonly string[] SupportedFileExtensions = { "png", "svg" };
#endregion
#region Contructor
public ParticipantImageProvider(ITradingMasterDataProvider tradingMasterDataProvider,
IDirectoryManager directoryManager,
ParticipantImageManagementConfiguration config,
IMultiLogger logger,
IModuleConfigurationDataProvider moduleConfigurationDataProvider,
JsonSerializerSettings jsonSerializerSettings,
LogoManagementColorCodesConfiguration colorCodesConfig)
{
this.tradingMasterDataProvider = tradingMasterDataProvider;
this.directoryManager = directoryManager;
this.jsonSerializerSettings = jsonSerializerSettings;
this.moduleConfigurationDataProvider = moduleConfigurationDataProvider;
this.colorCodesConfig = colorCodesConfig;
this.config = config;
this.logger = logger;
}
#endregion
#region Get Participants
public async Task<Tuple<ParticipantSaveRequest, string>> GetParticipantsByCompetitionIdAsync(string competitionId, string sportId, bool isSyncRequired, IIdentity userIdentity)
{
try
{
//Fetching participantImages from Db by sport.
var participantImages = GetParticipantImagesBySportId(sportId);
//Fetching participants from trading.
var participantsFromTrading = await tradingMasterDataProvider.GetParticipantsByCompetition(competitionId);
if (!isSyncRequired)
{
return new Tuple<ParticipantSaveRequest, string>(ParticipantImageExtensions.ToDataModel(participantsFromTrading, participantImages, sportId, this.config.ImageUriFormat, null), string.Empty);
}
return SyncParticipantsWithTrading(participantsFromTrading, sportId, competitionId, participantImages, userIdentity);
}
catch (Exception ex)
{
logger.LogError(ex, "An error occurred while loading participants from trading");
throw;
}
}
public IEnumerable<ParticipantSaveRequest> GetParticipants()
{
var participantsBucket = GetLogoManagementModule()
.SelectMany(bucket =>
{
var participants = bucket.DeserializeJsonContent<CompetitionParticipant>();
return participants?.Where(p => p.Participants.Any(a => a.Participants.Any())).ToList();
});
if (participantsBucket.Any())
{
return ResolveParticipants(participantsBucket.Where(p => !string.IsNullOrEmpty(p.SportId)));
}
return null;
}
public Dictionary<string, IEnumerable<ParticipantsModel>> GetParticipantDetails()
{
var participants = GetLogoManagementModule()
.SelectMany(bucket =>
{
var participantsBucket = bucket.DeserializeJsonContent<CompetitionParticipant>();
var participants = MapImagesToParticipants(participantsBucket.SelectMany(pc => pc.Participants.SelectMany(p => p.Participants)),
participantsBucket.SelectMany(p => p.ParticipantImages));
return participants;
});
var participantsList = JsonConvert.DeserializeObject<IEnumerable<ParticipantsModel>>(JsonConvert.SerializeObject(participants));
return participantsList.Where(p => !string.IsNullOrEmpty(p.CompetitionId)).GroupBy(p => p.CompetitionId).ToDictionary(pic => pic.Key, pic => pic.AsEnumerable());
}
#endregion
#region Get Participant Requests
private static IEnumerable<Participant> GetParticipantRequest(IEnumerable<Participant> participants, string competitionId)
{
return participants.SelectMany(participant =>
{
return new List<Participant>() { new Participant {
ParticipantId=participant.ParticipantId,
ParticipantName=participant.ParticipantName,
NickName=participant.NickName,
TriCode=participant.TriCode,
DarkColor=participant.DarkColor,
LightColor=participant.LightColor,
LogoColor=participant.LogoColor,
CompetitionId=competitionId,
} };
});
}
private static IEnumerable<ParticipantImageInfo> GetParticipantImageRequest(IEnumerable<Participant> participants)
{
return participants.SelectMany(participant =>
{
return new List<ParticipantImageInfo>() { new ParticipantImageInfo {
ParticipantId=participant.ParticipantId,
Logo=participant.Logo,
HomeJersey=participant.HomeJersey,
AwayJersey=participant.AwayJersey,
Cap=participant.Cap,
Helmet=participant.Helmet,
Headshot=participant.Headshot,
Silhouette=participant.Silhouette,
LogoId=participant.LogoId,
HomeJerseyId=participant.HomeJerseyId,
AwayJerseyId=participant.AwayJerseyId,
CapId=participant.CapId,
HelmetId=participant.HelmetId,
HeadshotId=participant.HeadshotId,
SilhouetteId=participant.SilhouetteId,
} };
});
}
#endregion
#region Save participants
public ParticipantImageResponse SetParticipants(ParticipantSaveRequest participants, IIdentity userIdentity)
{
var response = new ParticipantImageResponse()
{
SuccessMessage = string.Empty,
ErrorMessage = string.Empty,
ParticipantIds = new List<string>()
};
if (participants != null && participants.Participants.Any())
{
CompetitionParticipant request = new CompetitionParticipant();
var sportId = participants.Competition.Sport.Id;
//Saving participant images
var setParticipantImageageResponse = SetParticipantImages(participants, userIdentity, sportId);
var participantsList = GetParticipantRequest(participants.Participants, participants.Competition.Competition.Id);
var participantRequest = new ParticipantSaveRequest()
{
Participants = participantsList,
Competition = participants.Competition,
};
//Checking if the sport available in db
var existingCompetitionParticipants = GetLogoManagementModule();
var existingParticipants = existingCompetitionParticipants
.FirstOrDefault(p => p.ContentKey == sportId).DeserializeJsonContent<CompetitionParticipant>().FirstOrDefault();
if (existingParticipants != null)
{
request = GetCompetitionParticipantRequest(existingParticipants, participantRequest);
}
else
{
request.Participants = new List<ParticipantSaveRequest>()
{
new ParticipantSaveRequest()
{
Participants = participantRequest.Participants,
Competition = participantRequest.Competition
}
};
}
request.SportId = sportId;
var contentKey = sportId.ToString(CultureInfo.InvariantCulture);
var jsonContent = JsonConvert.SerializeObject(new[] { request }, jsonSerializerSettings);
try
{
moduleConfigurationDataProvider
.SetModuleConfigurationBucket(
Modules.LogoManagement,
contentKey,
Constants.LogoManagementSchemaVersion,
jsonContent,
userIdentity.GetUserName());
foreach (var file in setParticipantImageageResponse.imagesToDelete)
{
DeleteParticipantImage(file);
}
if (setParticipantImageageResponse.participantIds.Any())
{
response.ParticipantIds = setParticipantImageageResponse.participantIds;
}
response.SuccessMessage = "Participants saved successfully";
}
catch (DataAccessException ex)
{
logger.LogError(ex, "An error occurred while saving Participants");
response.ErrorMessage = "An error occurred while saving Participants";
}
}
return response;
}
private (List<string> imagesToDelete, List<string> participantIds) SetParticipantImages(ParticipantSaveRequest participants, IIdentity userIdentity, string sportId)
{
try
{
var imagesToDelete = new List<string>();
var participantIds = new List<string>();
var participantImageList = new List<ParticipantImageInfo>();
if (participants != null && participants.Participants.Any())
{
var particlipantImageRequest = GetParticipantImageRequest(participants.Participants);
foreach (var participantImage in particlipantImageRequest)
{
foreach (TeamImageType imageType in Enum.GetValues(typeof(ImageType.TeamImageType)))
{
if (imageType == TeamImageType.Logo)
{
var response = UploadParticipantImage(sportId, (participantImage.LogoId, participantImage.Logo));
participantImage.LogoId = response.Image;
participantImage.Logo = !string.IsNullOrEmpty(participantImage.LogoId) ? participantImage.LogoId : null;
if (!string.IsNullOrEmpty(response.OldFileName)) { imagesToDelete.Add(response.OldFileName); }
if (response.HasError) { participantIds.Add($"{participantImage.ParticipantId}-{"Logo"}"); }
}
if (imageType == TeamImageType.HomeJersey)
{
var response = UploadParticipantImage(sportId, (participantImage.HomeJerseyId, participantImage.HomeJersey));
participantImage.HomeJerseyId = response.Image;
participantImage.HomeJersey = !string.IsNullOrEmpty(participantImage.HomeJerseyId) ? participantImage.HomeJerseyId : null;
if (!string.IsNullOrEmpty(response.OldFileName)) { imagesToDelete.Add(response.OldFileName); }
if (response.HasError) { participantIds.Add($"{participantImage.ParticipantId}-{"HomeJersey"}"); }
}
if (imageType == TeamImageType.AwayJersey)
{
var response = UploadParticipantImage(sportId, (participantImage.AwayJerseyId, participantImage.AwayJersey));
participantImage.AwayJerseyId = response.Image;
participantImage.AwayJersey = !string.IsNullOrEmpty(participantImage.AwayJerseyId) ? participantImage.AwayJerseyId : null;
if (!string.IsNullOrEmpty(response.OldFileName)) { imagesToDelete.Add(response.OldFileName); }
if (response.HasError) { participantIds.Add($"{participantImage.ParticipantId}-{"AwayJersey"}"); }
}
if (imageType == TeamImageType.Cap)
{
var response = UploadParticipantImage(sportId, (participantImage.CapId, participantImage.Cap));
participantImage.CapId = response.Image;
participantImage.Cap = !string.IsNullOrEmpty(participantImage.CapId) ? participantImage.CapId : null;
if (!string.IsNullOrEmpty(response.OldFileName)) { imagesToDelete.Add(response.OldFileName); }
if (response.HasError) { participantIds.Add($"{participantImage.ParticipantId}-{"Cap"}"); }
}
if (imageType == TeamImageType.Helmet)
{
var response = UploadParticipantImage(sportId, (participantImage.HelmetId, participantImage.Helmet));
participantImage.HelmetId = response.Image;
participantImage.Helmet = !string.IsNullOrEmpty(participantImage.HelmetId) ? participantImage.HelmetId : null;
if (!string.IsNullOrEmpty(response.OldFileName)) { imagesToDelete.Add(response.OldFileName); }
if (response.HasError) { participantIds.Add($"{participantImage.ParticipantId}-{"Helmet"}"); }
}
if (imageType == TeamImageType.Headshot)
{
var response = UploadParticipantImage(sportId, (participantImage.HeadshotId, participantImage.Headshot));
participantImage.HeadshotId = response.Image;
participantImage.Headshot = !string.IsNullOrEmpty(participantImage.HeadshotId) ? participantImage.HeadshotId : null;
if (!string.IsNullOrEmpty(response.OldFileName)) { imagesToDelete.Add(response.OldFileName); }
if (response.HasError) { participantIds.Add($"{participantImage.ParticipantId}-{"Headshot"}"); }
}
if (imageType == TeamImageType.Silhouette)
{
var response = UploadParticipantImage(sportId, (participantImage.SilhouetteId, participantImage.Silhouette));
participantImage.SilhouetteId = response.Image;
participantImage.Silhouette = !string.IsNullOrEmpty(participantImage.SilhouetteId) ? participantImage.SilhouetteId : null;
if (!string.IsNullOrEmpty(response.OldFileName)) { imagesToDelete.Add(response.OldFileName); }
if (response.HasError) { participantIds.Add($"{participantImage.ParticipantId}-{"Silhouette"}"); }
}
}
participantImageList.Add(participantImage);
}
CompetitionParticipant request = new CompetitionParticipant();
//Getting saved records to get participants by sportId
var existingCompetitionParticipants = GetLogoManagementModule();
var existingParticipantImages = existingCompetitionParticipants
.FirstOrDefault(p => p.ContentKey == sportId).DeserializeJsonContent<CompetitionParticipant>().FirstOrDefault();
if (existingParticipantImages != null)
{
request.ParticipantImages = existingParticipantImages.ParticipantImages.Any() ? participantImageList.Union(existingParticipantImages.ParticipantImages).DistinctBy(p => p.ParticipantId) : participantImageList;
request.Competitions = existingParticipantImages.Competitions;
request.Participants = existingParticipantImages.Participants;
}
else
{
request.ParticipantImages = participantImageList;
}
request.SportId = sportId;
var contentKey = sportId.ToString(CultureInfo.InvariantCulture);
var jsonContent = JsonConvert.SerializeObject(new[] { request }, jsonSerializerSettings);
moduleConfigurationDataProvider
.SetModuleConfigurationBucket(
Modules.LogoManagement,
contentKey,
Constants.LogoManagementSchemaVersion,
jsonContent,
userIdentity.GetUserName());
}
return (imagesToDelete, participantIds);
}
catch (Exception e)
{
logger.LogError(e, "An error occurred while saving participant images");
throw;
}
}
private UploadLogoResponse UploadParticipantImage(string sportId, (string imageId, string image) imgObj)
{
string oldFileName = string.Empty;
if (!string.IsNullOrEmpty(imgObj.image))
{
if (imgObj.image?.Substring(0, 4) == ImageKey)
{
return UploadImages(sportId, imgObj.imageId, imgObj.image);
} else
{
return new UploadLogoResponse { Image = imgObj.imageId ?? string.Empty, OldFileName = string.Empty, HasError = false };
}
}
else if (string.IsNullOrEmpty(imgObj.image) && !string.IsNullOrEmpty(imgObj.imageId))
{
oldFileName = imgObj.imageId;
}
// string imageName = Path.GetFileName(imgObj.image);
return new UploadLogoResponse() { Image = imgObj.imageId, OldFileName = oldFileName };
}
private UploadLogoResponse UploadImages(string sportId, string teamImageId, string teamImage)
{
string imageId, oldImage;
bool hasError = false;
try
{
var imageExt = GetImageExtension(teamImage);
if (SupportedFileExtensions.Contains(imageExt))
{
imageId = string.Format(@"{0}.{1}", Guid.NewGuid().ToString().Substring(0, 8), imageExt);
var filePath = BuildFilePath(sportId, imageId.ToString());
directoryManager.UploadFile(teamImage, filePath);
oldImage = imageId ?? string.Empty;
}
else
{
imageId = teamImageId ?? string.Empty;
oldImage = string.Empty;
}
}
catch (Exception e)
{
logger.LogError(e, "An error occurred while uploading participant images");
imageId = string.Empty;
oldImage = string.Empty;
hasError = true;
}
return new UploadLogoResponse { Image = imageId, OldFileName = oldImage, HasError = hasError };
}
private CompetitionParticipant GetCompetitionParticipantRequest(CompetitionParticipant response, ParticipantSaveRequest request)
{
var matchedCompetition = response.Participants.FirstOrDefault(p => p.Competition.Competition.Id ==
request.Competition.Competition.Id);
//checking if same competition and participant record exists in bd, if exists removing the record in db
// adding updated record to existing collection
if (matchedCompetition != null)
{
var remaininingCompetitions = response.Participants
.Where(p => p.Competition.Competition.Id != request.Competition.Competition.Id).ToList();
remaininingCompetitions.Add(request);
return new CompetitionParticipant()
{
Participants = remaininingCompetitions,
Competitions = response.Competitions,
ParticipantImages = response.ParticipantImages,
};
}
else
{
return new CompetitionParticipant()
{
Participants = response.Participants.Append(request),
Competitions = response.Competitions,
ParticipantImages = response.ParticipantImages,
};
}
}
#endregion
#region Delete Images
private void DeleteParticipantImage(string filePath)
{
try
{
var file = new FileInfo(filePath);
if (File.Exists(file.FullName))
{
directoryManager.DeleteFile(filePath);
}
}
catch (Exception e)
{
logger.LogError(e, "An error occurred while deleting participant images");
throw;
}
}
#endregion
#region Helper Methods
private IEnumerable<ModuleConfigurationBucket> GetLogoManagementModule()
{
try
{
return moduleConfigurationDataProvider.GetAllModuleConfigurationBuckets(Modules.LogoManagement, Constants.LogoManagementSchemaVersion);
}
catch (Exception e)
{
logger.LogError(e, "An error occurred while loading LogoManagementModule - Participant");
throw;
}
}
private string BuildFilePath(string sportId, string imageFileName) => $"{config.ImageStoragePath}\\{sportId}\\{imageFileName}";
private IEnumerable<ParticipantImageInfo> GetParticipantImagesBySportId(string sportId)
{
var participantImagesBySportId = GetLogoManagementModule()
.Where(p => p.ContentKey == sportId).FirstOrDefault()
.DeserializeJsonContent<CompetitionParticipant>();
if (participantImagesBySportId != null)
{
return participantImagesBySportId.SelectMany(p => p.ParticipantImages).ToList();
}
return null;
}
private ParticipantSaveRequest GetParticipantsBySportAndCompetition(string sportId, string competitionId)
{
var participants = GetLogoManagementModule()
.Where(bucket => bucket.ContentKey == sportId).FirstOrDefault()
.DeserializeJsonContent<CompetitionParticipant>();
if (participants.Any())
{
var competitionParticipants = participants.Select(cp => cp.Participants
.FirstOrDefault(p => p.Competition.Competition.Id == competitionId)).FirstOrDefault();
if (competitionParticipants != null)
{
return new ParticipantSaveRequest()
{
Competition = competitionParticipants.Competition,
Participants = competitionParticipants.Participants,
ParticipantImages = participants.First().ParticipantImages,
};
}
}
return null;
}
private IEnumerable<Participant> MapImagesToParticipants(IEnumerable<Participant> participants, IEnumerable<ParticipantImageInfo> participantImages, string sportId = null)
{
if (participants != null && participantImages != null && participantImages.Any())
{
return participants.Select(x => MapImages(x, participantImages, sportId));
}
return participants;
}
private Participant MapImages(Participant participant, IEnumerable<ParticipantImageInfo> participantImages, string sportId = null)
{
var imageDetails = participantImages.FirstOrDefault(p => p.ParticipantId == participant.ParticipantId);
if (imageDetails != null)
{
if (sportId == null)
{
participant.Logo = imageDetails.Logo;
participant.HomeJersey = imageDetails.HomeJersey;
participant.AwayJersey = imageDetails.AwayJersey;
participant.Cap = imageDetails.Cap;
participant.Helmet = imageDetails.Helmet;
participant.Headshot = imageDetails.Headshot;
participant.Silhouette = imageDetails.Silhouette;
}
else
{
participant = ParticipantImageExtensions.MapParticipantImages(participant, imageDetails, sportId, this.config.ImageUriFormat);
};
}
return participant;
}
private IEnumerable<ParticipantSaveRequest> ResolveParticipants(IEnumerable<CompetitionParticipant> competitionParticipants)
{
var participantsWithImages = new List<ParticipantSaveRequest>();
foreach (var competitionParticipant in competitionParticipants.SelectMany(p => p.Participants))
{
participantsWithImages.Add(new ParticipantSaveRequest()
{
Participants = competitionParticipant.Participants,
Competition = competitionParticipant.Competition,
ParticipantImages = competitionParticipants.SelectMany(pImages => pImages.ParticipantImages),
ImagePath = this.config.ImageUriFormat,
});
}
return participantsWithImages;
}
private string GetImageExtension(string image)
{
var imageType = image.Split(';')[0].Split('/')[1];
switch (imageType)
{
case "svg+xml":
return ImageExtensions.Svg.ToString().ToLower();
case "png":
return ImageExtensions.Png.ToString().ToLower();
}
return string.Empty;
}
private Tuple<ParticipantSaveRequest, string> SyncParticipantsWithTrading(IEnumerable<Trading.Model.Player> players, string sportId, string competitionId, IEnumerable<ParticipantImageInfo> participantImages, IIdentity userIdentity)
{
try
{
var competitionParticipants = GetParticipantsBySportAndCompetition(sportId, competitionId);
if (competitionParticipants == null)
{
return null;
}
var imageMappedParticipants = ParticipantImageExtensions.ToDataModel(players, participantImages, sportId, this.config.ImageUriFormat, competitionParticipants.Participants);
if (!competitionParticipants.Participants.Any())
{
return new Tuple<ParticipantSaveRequest, string>(imageMappedParticipants, "There are no changes to sync with trading");
}
var tradingParticipantsIds = players.Select(p => p.Id.ToString()).ToList();
var dbParticipantsIds = competitionParticipants.Participants.Select(p => p.ParticipantId).ToList();
var commonParticipantIds = tradingParticipantsIds.Intersect(dbParticipantsIds).ToList();
if (tradingParticipantsIds.Count == dbParticipantsIds.Count && tradingParticipantsIds.Count == commonParticipantIds.Count)
{
return new Tuple<ParticipantSaveRequest, string>(imageMappedParticipants, "There are no changes to sync with trading");
}
var saveRequest = new ParticipantSaveRequest()
{
Participants = imageMappedParticipants.Participants,
Competition = competitionParticipants.Competition,
ParticipantImages = competitionParticipants.ParticipantImages
};
var response = SetParticipants(saveRequest, userIdentity);
if (response.ErrorMessage == string.Empty)
{
return new Tuple<ParticipantSaveRequest, string>(imageMappedParticipants, "Participants are in sync with trading");
}
return new Tuple<ParticipantSaveRequest, string>(imageMappedParticipants, "An error occurred while saving participants");
}
catch (Exception ex)
{
logger.LogError(ex, "An error occurred while doing participants sync with trading");
throw;
}
}
#endregion
#region GetColorCodes
public IEnumerable<ColorCode> GetColorCodes()
{
return this.colorCodesConfig.ColorCodes;
}
#endregion
}
}

