public ChallengeCustomDataComponent() { mifnexsoEntities = new MIFNEXSOEntities(); challengeCustomData = new ChallengeCustomData(); challengeCustomData.ChallengeCustomDatalId = Guid.Empty; challengeCustomData.ChallengeReference = string.Empty; mifnexsoEntities.ChallengeCustomData.AddObject(challengeCustomData); }
public ChallengeCustomDataComponent(string challengeReference, string language) { if (challengeReference != string.Empty && language != string.Empty) { mifnexsoEntities = new MIFNEXSOEntities(); try { challengeCustomData = mifnexsoEntities.ChallengeCustomData.FirstOrDefault(a => a.ChallengeReference == challengeReference && a.Language == language); if (challengeCustomData == null) { challengeCustomData = new ChallengeCustomData(); challengeCustomData.ChallengeCustomDatalId = Guid.Empty; challengeCustomData.ChallengeReference = string.Empty; mifnexsoEntities.ChallengeCustomData.AddObject(challengeCustomData); } } catch (Exception) { throw; } } }
/// <summary> /// Load the timeline (Home page of the challenge) /// </summary> /// <param name="challengeCustomData"></param> /// <param name="dictionary"></param> /// <returns></returns> private List <TimeLine> GenerateTimeLine(ChallengeCustomData challengeCustomData, List <GenericObject> dictionary) { List <TimeLine> listReturn = new List <TimeLine>(); string format = "MMMM d \\'yy"; if (Thread.CurrentThread.CurrentCulture.Name == "es-ES") { format = "d MMMM \\'yy"; } if (challengeCustomData.ChallengeSchema.PreLaunch.GetValueOrDefault(DateTime.MinValue) != DateTime.MinValue) { var list = dictionary.SingleOrDefault(a => a.value1 == "Pre-Launch"); string title = Localization.GetString("Pre-Launch", LocalResourceFile); if (list != null) { title = list.value2; } listReturn.Add(new TimeLine() { DateValue = challengeCustomData.ChallengeSchema.PreLaunch.GetValueOrDefault(), Title = title, ToolTip = title, State = "nextStep", FormatedDateTime = challengeCustomData.ChallengeSchema.PreLaunch.GetValueOrDefault().ToString(format) } ); } if (challengeCustomData.ChallengeSchema.Launch.GetValueOrDefault(DateTime.MinValue) != DateTime.MinValue) { var list = dictionary.SingleOrDefault(a => a.value1 == "Launch"); string title = Localization.GetString("Launch", LocalResourceFile); if (list != null) { title = list.value2; } listReturn.Add(new TimeLine() { DateValue = challengeCustomData.ChallengeSchema.Launch.GetValueOrDefault(), Title = title, ToolTip = title, State = "nextStep", FormatedDateTime = challengeCustomData.ChallengeSchema.Launch.GetValueOrDefault().ToString(format) } ); } if (challengeCustomData.ChallengeSchema.EntryFrom.GetValueOrDefault(DateTime.MinValue) != DateTime.MinValue) { if (challengeCustomData.ChallengeSchema.EntryFrom.GetValueOrDefault() != challengeCustomData.ChallengeSchema.Launch.GetValueOrDefault()) { var list = dictionary.SingleOrDefault(a => a.value1 == "AvailableEntryFrom"); string title = Localization.GetString("AvailableEntryFrom", LocalResourceFile); if (list != null) { title = list.value2; } listReturn.Add(new TimeLine() { DateValue = challengeCustomData.ChallengeSchema.EntryFrom.GetValueOrDefault(), Title = title, ToolTip = title, State = "nextStep", FormatedDateTime = challengeCustomData.ChallengeSchema.EntryFrom.GetValueOrDefault().ToString(format) } ); } } if (challengeCustomData.ChallengeSchema.EntryTo.GetValueOrDefault(DateTime.MinValue) != DateTime.MinValue) { var list = dictionary.SingleOrDefault(a => a.value1 == "AvailableEntryTo"); string title = Localization.GetString("AvailableEntryTo", LocalResourceFile); if (list != null) { title = list.value2; } listReturn.Add(new TimeLine() { DateValue = challengeCustomData.ChallengeSchema.EntryTo.GetValueOrDefault(), Title = title, ToolTip = title, State = "nextStep", FormatedDateTime = challengeCustomData.ChallengeSchema.EntryTo.GetValueOrDefault().ToString(format) } ); } if (challengeCustomData.ChallengeSchema.ScoringL1From.GetValueOrDefault(DateTime.MinValue) != DateTime.MinValue) { var list = dictionary.SingleOrDefault(a => a.value1 == "EvaluationFrom"); string title = Localization.GetString("EvaluationFrom", LocalResourceFile); if (list != null) { title = list.value2; } listReturn.Add(new TimeLine() { DateValue = challengeCustomData.ChallengeSchema.ScoringL1From.GetValueOrDefault(), Title = title, ToolTip = title, State = "nextStep", FormatedDateTime = challengeCustomData.ChallengeSchema.ScoringL1From.GetValueOrDefault().ToString(format) } ); } if (challengeCustomData.ChallengeSchema.ScoringL1To.GetValueOrDefault(DateTime.MinValue) != DateTime.MinValue) { var list = dictionary.SingleOrDefault(a => a.value1 == "EvaluationTo"); string title = Localization.GetString("EvaluationTo", LocalResourceFile); if (list != null) { title = list.value2; } listReturn.Add(new TimeLine() { DateValue = challengeCustomData.ChallengeSchema.ScoringL1To.GetValueOrDefault(), Title = title, ToolTip = title, State = "nextStep", FormatedDateTime = challengeCustomData.ChallengeSchema.ScoringL1To.GetValueOrDefault().ToString(format) } ); } if (challengeCustomData.ChallengeSchema.Closed.GetValueOrDefault(DateTime.MinValue) != DateTime.MinValue) { var list = dictionary.SingleOrDefault(a => a.value1 == "Closed"); string title = Localization.GetString("Closed", LocalResourceFile); if (list != null) { title = list.value2; } listReturn.Add(new TimeLine() { DateValue = challengeCustomData.ChallengeSchema.Closed.GetValueOrDefault(), Title = title, ToolTip = title, State = "nextStep", FormatedDateTime = challengeCustomData.ChallengeSchema.Closed.GetValueOrDefault().ToString(format) } ); } TimeLine lastObject = null; foreach (var item in listReturn) { if (item.DateValue <= DateTime.Now) { item.State = "prevStep"; } else { if (lastObject != null) { lastObject.State = "currentStep"; } break; } lastObject = item; } return(listReturn); }
protected string createContext(ChallengeCustomData challengeCustomData, ChallengePage challengePage) { //main contenxt NZChallengePage.ContextPage objReturn = new NZChallengePage.ContextPage(); objReturn.ChallengeCustomDatalId = challengeCustomData.ChallengeCustomDatalId.ToString(); objReturn.ChallengeReference = challengeCustomData.ChallengeReference; objReturn.SolutionType = solutionType; objReturn.Description = challengeCustomData.Description; objReturn.Language = challengeCustomData.Language; objReturn.TagLine = challengeCustomData.TagLine; objReturn.Tags = challengeCustomData.Tags; objReturn.Title = challengeCustomData.Title; ChallengeComponent challengeComponent = new ChallengeComponent(challengeCustomData.ChallengeReference); var file = challengeComponent.Challenge.ChallengeFiles.FirstOrDefault(x => x.Language == challengeCustomData.Language && x.ObjectType == "Banner Challenge" && (x.Delete == null || x.Delete == false)); if (file != null) { objReturn.BannerImage = file.ObjectLocation; } objReturn.ChallengeSchemaContext = new ChallengeSchemaContext(); objReturn.ChallengeSchemaContext.Closed = challengeCustomData.ChallengeSchema.Closed.GetValueOrDefault(DateTime.MinValue).ToString();; objReturn.ChallengeSchemaContext.EnterUrl = challengeCustomData.ChallengeSchema.EnterUrl; objReturn.ChallengeSchemaContext.EntryFrom = challengeCustomData.ChallengeSchema.EntryFrom.GetValueOrDefault(DateTime.MinValue).ToString(); objReturn.ChallengeSchemaContext.EntryTo = challengeCustomData.ChallengeSchema.EntryTo.GetValueOrDefault(DateTime.MinValue).ToString(); objReturn.ChallengeSchemaContext.Flavor = challengeCustomData.ChallengeSchema.Flavor; objReturn.ChallengeSchemaContext.Launch = challengeCustomData.ChallengeSchema.Launch.GetValueOrDefault(DateTime.MinValue).ToString(); objReturn.ChallengeSchemaContext.OutUrl = challengeCustomData.ChallengeSchema.OutUrl; objReturn.ChallengeSchemaContext.PreLaunch = challengeCustomData.ChallengeSchema.PreLaunch.GetValueOrDefault(DateTime.MinValue).ToString(); objReturn.ChallengeSchemaContext.PublishType = challengeCustomData.ChallengeSchema.PublishType; objReturn.ChallengeSchemaContext.ScoringL1From = challengeCustomData.ChallengeSchema.ScoringL1From.GetValueOrDefault(DateTime.MinValue).ToString(); objReturn.ChallengeSchemaContext.ScoringL2From = challengeCustomData.ChallengeSchema.ScoringL2From.GetValueOrDefault(DateTime.MinValue).ToString(); objReturn.ChallengeSchemaContext.Url = challengeCustomData.ChallengeSchema.Url; var judgesPage = challengeCustomData.ChallengePages.SingleOrDefault(a => a.Reference == "judges"); if (judgesPage != null) { objReturn.Judges = GetGenericObjectList(judgesPage.Content); } objReturn.Dictionary = GetGenericListDictionary(challengeCustomData.Tags); objReturn.TimesLine = GenerateTimeLine(challengeCustomData, objReturn.Dictionary); objReturn.CurrentPageContext = new CurrentPageContext(); objReturn.CurrentPageContext.ChallengePageId = challengePage.ChallengePageId.ToString(); objReturn.CurrentPageContext.Content = challengePage.Content; objReturn.CurrentPageContext.ContentType = challengePage.ContentType; objReturn.CurrentPageContext.Description = challengePage.Description; objReturn.CurrentPageContext.Order = challengePage.Order.GetValueOrDefault(0).ToString(); objReturn.CurrentPageContext.Reference = challengePage.Reference; objReturn.CurrentPageContext.Tagline = challengePage.Tagline; objReturn.CurrentPageContext.Title = challengePage.Title; objReturn.CurrentPageContext.Url = challengePage.Url; objReturn.CurrentPageContext.Visibility = challengePage.Visibility; objReturn.Eligibility = GetGenericElegibility(challengeCustomData.EligibilityTemplate); switch (challengePage.Reference) { case "judges": { objReturn.CurrentPageContext.GenericObject = objReturn.Judges; break; } case "faq": { objReturn.CurrentPageContext.GenericObject = GetGenericFAQ(challengePage.Content); break; } case "partners": { objReturn.CurrentPageContext.GenericObject = GetGenericObjectList(challengePage.Content); break; } } objReturn.PagesContext = new List <PagesContext>(); foreach (var item in challengeCustomData.ChallengePages.OrderBy(a => a.Order)) { if (item.Title != string.Empty) { objReturn.PagesContext.Add(new PagesContext { Tagline = item.Tagline, Title = item.Title, Url = item.Url, Visibility = item.Visibility }); } } return(JsonConvert.SerializeObject(objReturn)); }