public async Task <OwnedCarTrans> GetDefaultCar(int personaId) { AppPersona persona = await _personaService.FindPersonaById(personaId); await _context.Entry(persona) .Collection(p => p.OwnedCars) .LoadAsync(); return(ConvertOwnedCarToContract(persona.OwnedCars[persona.SelectedCarIndex])); }
private PersonaBase ConvertPersonaEntityToPersonaBase(AppPersona persona) => new PersonaBase { Motto = persona.Motto, Badges = new List <BadgePacket>(), IconIndex = persona.IconIndex, Level = persona.Level, PersonaId = persona.ID, Presence = 1, Name = persona.Name, Score = persona.Score, UserId = persona.User.Id };
public async Task <AppPersona> FindPersonaById(int personaId) { AppPersona persona = await _dbContext.Personas.Include(p => p.User) .FirstOrDefaultAsync(p => p.ID == personaId); if (persona == null) { throw new ArgumentException("Cannot find persona with ID " + personaId); } return(persona); }
public async Task <List <PersonaBase> > GetPersonaBaseFromList(List <long> personaIds) { List <PersonaBase> personas = new List <PersonaBase>(); foreach (var personaId in personaIds.Select(Convert.ToInt32)) { AppPersona persona = await FindPersonaById(personaId); personas.Add(ConvertPersonaEntityToPersonaBase(persona)); } return(personas); }
private ProfileData ConvertPersonaToProfile(AppPersona persona) { return(new ProfileData { Name = persona.Name, Boost = persona.Boost, Cash = persona.Cash, ccar = new List <PersonaCCar>(), IconIndex = persona.IconIndex, Level = persona.Level, Motto = persona.Motto, PercentToLevel = 0, PersonaId = persona.ID, Rating = persona.Rating }); }
public ProfileData GetPersonaInfo(AppPersona persona) { return(new ProfileData { Motto = persona.Motto, Badges = new List <BadgePacket>(), Cash = persona.Cash, IconIndex = persona.IconIndex, PersonaId = persona.ID, Level = persona.Level, Rep = persona.Reputation, RepAtCurrentLevel = (int)persona.ReputationAtLevel, Score = persona.Score, Name = persona.Name }); }
public async Task SecureLoginPersona(AppUser user, int personaId) { if (personaId != 0) { AppPersona persona = await _dbContext.Personas.Include(p => p.User) .FirstOrDefaultAsync(p => p.User.Id == user.Id); if (persona == null) { throw new ArgumentException($"Persona {personaId} either does not exist or is not available"); } } UserSession session = await GetSession(user); session.PersonaID = personaId; await UpdateSession(user, session); }
public async Task <CarSlotInfoTrans> GetCarSlots(int personaId) { AppPersona persona = await _personaService.FindPersonaById(personaId); await _context.Entry(persona) .Collection(p => p.OwnedCars) .LoadAsync(); CarSlotInfoTrans carSlotInfoTrans = new CarSlotInfoTrans(); carSlotInfoTrans.OwnedCarSlotsCount = persona.OwnedCars.Count; carSlotInfoTrans.DefaultOwnedCarIndex = persona.SelectedCarIndex; carSlotInfoTrans.CarsOwnedByPersona = new List <OwnedCarTrans>(); carSlotInfoTrans.ObtainableSlots = new List <ProductTrans>(); foreach (var personaOwnedCar in persona.OwnedCars) { carSlotInfoTrans.CarsOwnedByPersona.Add(ConvertOwnedCarToContract(personaOwnedCar)); } return(carSlotInfoTrans); }