public EventScoreService LazyLoadEventScoreService(string userToken, string userName, int eventId) { if (eventScoreServices.ContainsKey(eventId)) { return(eventScoreServices[eventId]); } var eventScoreService = new EventScoreService(userToken, eventId, userName); eventScoreServices.Add(eventId, eventScoreService); return(eventScoreService); }
public async Task<ActionResult> Index(int eventbriteOrderNo, int dddEventId, string clientToken) { try { UserInfo registeredUser = null; var userService = new UserService(); var user = userService.GetUserByEventbriteOrder(dddEventId, eventbriteOrderNo); if (user == null) { var eventMgr = new EventsService(); var eventInfo = eventMgr.GetServerEventData(dddEventId); var eventbriteService = new EventbriteService(eventInfo.EventbriteToken); var eventbriteUserInfo = await eventbriteService.GetUserRegistrationInfo(eventbriteOrderNo, eventInfo.EventbriteEventId); var newToken = Guid.NewGuid().ToString(); userService.AddUser(dddEventId, eventbriteOrderNo, eventbriteUserInfo.firstName, eventbriteUserInfo.lastName, newToken, clientToken); registeredUser = new UserInfo { firstName = eventbriteUserInfo.firstName, lastName = eventbriteUserInfo.lastName, token = newToken }; } else { registeredUser = new UserInfo { firstName = user.FirstName, lastName = user.LastName, token = user.RowKey }; } var eventScoreService = new EventScoreService(registeredUser.token, dddEventId, user.FirstName + "_" + user.LastName); registeredUser.eventScore = eventScoreService.GetCurrentEventScore(); return new JsonNetResult(registeredUser); } catch (Exception) { throw new InvalidDataException("Failed to get user"); } }
public EventScoreService LazyLoadEventScoreService(string userToken, string userName, int eventId) { if (eventScoreServices.ContainsKey(eventId)) return eventScoreServices[eventId]; var eventScoreService = new EventScoreService(userToken, eventId, userName); eventScoreServices.Add(eventId, eventScoreService); return eventScoreService; }