public static IChallenge ToEntity(this ChallengeModel model) { var challenge = new Challenge( ChallengeId.FromGuid(model.Id), new ChallengeName(model.Name), Game.FromValue(model.Game), new BestOf(model.BestOf), new Entries(model.Entries), new ChallengeTimeline(new DateTimeProvider(model.Timeline.CreatedAt), new ChallengeDuration(TimeSpan.FromTicks(model.Timeline.Duration))), model.ScoringItems.ToEntity()); foreach (var participant in model.Participants.Select(participant => participant.ToEntity())) { challenge.Register(participant); } if (model.Timeline.StartedAt.HasValue) { challenge.Start(new DateTimeProvider(model.Timeline.StartedAt.Value)); } if (model.SynchronizedAt.HasValue) { challenge.Synchronize(new DateTimeProvider(model.SynchronizedAt.Value)); } if (model.Timeline.ClosedAt.HasValue) { challenge.Close(new DateTimeProvider(model.Timeline.ClosedAt.Value)); } challenge.ClearDomainEvents(); return(challenge); }
// metoda privata care verifica daca problema este din cadrul unui concurs in desfasurare private bool IsChallengeActive(ChallengeModel challenge) { // verificam daca este in desfasurare if (challenge?.Contest != null) { // verificam daca este activata if (!challenge.Active) { return(false); } // verificam daca a trecut peste timpul admis if (challenge.Contest.Duration - (DateTime.Now - challenge.Contest.StartDate).TotalMinutes < 0) { return(false); } // verificam daca este inaintea inceperii concursului if (DateTime.Now.CompareTo(challenge.Contest.StartDate) < 0) { return(false); } } else { return(false); } return(true); }
private async Task Submit(string code) { var submitChallenge = new ChallengeModel { Solution = code, Tests = AppState.ActiveChallenge.Tests }; var output = await PublicClient.SubmitChallenge(submitChallenge); foreach (string result in output.Outputs.Select(x => x.Codeout)) { AppState.AddLineToOutput(result); } foreach (var result in output.Outputs) { System.Console.WriteLine($"test: {result.TestIndex}, result: {result.TestResult}, against: {result.Test.TestAgainst}, output: {result.Codeout}"); } bool challengeSucceed = output.Outputs.All(x => x.TestResult); _testResult = challengeSucceed ? TestResult.Pass : TestResult.Fail; //var debugString = challengeSucceed ? "True" : "False"; //System.Console.WriteLine($"isChallengeSucceed = {debugString}"); //_isChallengeFail = !challengeSucceed; //System.Console.WriteLine($"isChallengeFail = {_isChallengeFail}"); _isWorking = false; results = output; await InvokeAsync(StateHasChanged); }
protected async override void OnAppearing() { base.OnAppearing(); UpdateDetailView(); if (goal.Closed || goal.Completed) { editGoal.IsEnabled = false; } else if (!string.IsNullOrEmpty(goal.ChallengeId)) { challenge = (await App.client.GetTable <ChallengeModel>().Where(c => c.Id == goal.ChallengeId).ToListAsync()).FirstOrDefault(); if ((challenge.OwnerId == App.loggedInUser.Id)) { editGoal.IsEnabled = true; } else { editGoal.IsEnabled = false; } } else { editGoal.IsEnabled = true; } UpdateLeaderBoard(); }
public void Update(UIView container, ShareResponseModel shareResponse, ChallengeModel challenge, ChallengeDetailBaseViewController ctrl = null) { ResponseCode = shareResponse?.ResponseCode ?? 0; Controller = ctrl; //CGRect cell = TableView.RectForRowAtIndexPath(NSIndexPath.FromIndex(0)); Container = container; (Container as UIButton).TouchUpInside += CloseAction; btnCloseBgBottom.TouchUpInside += CloseAction; btnCloseBg.TouchUpInside += CloseAction; RoundImage.Image = UIImage.FromBundle("IconScoreTransactions"); //Commit float backgroundToOverlayWidthRatio = 0.9227f; //from spec nfloat width = container.Frame.Width * backgroundToOverlayWidthRatio; //float backgroundHeightToWidthRatio = 0.9529f; //from spec //nfloat height = width * backgroundHeightToWidthRatio; nfloat height = TableView.Frame.Y + CellHeight + 200; //cell.Height; nfloat x = (container.Frame.Width - width) / 2.0f; //center in overlay nfloat y = (container.Frame.Height - height) / 2.0f; //center in overlay Frame = new CGRect(x, y, width, height); //ChallengeImage.SetNeedsLayout(); /* * TableView.Source = new FeedTableSource(); * TableView.RowHeight = UITableView.AutomaticDimension; * TableView.EstimatedRowHeight = 130.0f; * TableView.ReloadData(); */ MessageText.Text = shareResponse.ResponseMessage; PointsText.Text = shareResponse.ResponseCode > 0 && challenge.PointValue > 0 ? challenge.PointValue + " pts added to your account" : ""; AddTriangularView(); }
private void CompletedChallengeButton_Click(object sender, RoutedEventArgs e) { Button button = sender as Button; int selectedChallengeIndex = CompletedJoinedChallengesListBox.Items.IndexOf(button.DataContext); ChallengeModel currentChallenge = (ChallengeModel)CompletedJoinedChallengesListBox.Items[selectedChallengeIndex]; Database.UnjoinChallenge(UserWindow.signedInUser.ID, currentChallenge.ID); LoadJoinedChallengesCards(); }
public static IChallenge ToEntity(this ChallengeModel model) { var entryFee = new EntryFee(model.EntryFeeAmount, CurrencyType.FromValue(model.EntryFeeCurrency)); var payout = new ChallengePayout(entryFee, new ChallengePayoutBuckets(model.PayoutBuckets.Select(bucket => bucket.ToEntity()))); var challenge = new Challenge(ChallengeId.FromGuid(model.Id), payout); challenge.ClearDomainEvents(); return(challenge); }
private void JoinChallengeButton_Unchecked(object sender, RoutedEventArgs e) { ToggleButton toggleButton = sender as ToggleButton; int selectedChallengeIndex = ChallengesListBox.Items.IndexOf(toggleButton.DataContext); ChallengeModel currentChallenge = (ChallengeModel)ChallengesListBox.Items[selectedChallengeIndex]; Database.UnjoinChallenge(UserWindow.signedInUser.ID, currentChallenge.ID); // Rrefresh Joined Challenges Cards in Home Page UserWindow.HomePageObject.LoadJoinedChallengesCards(); }
public void UpdateCellData(ChallengeModel item) { Reset(); ChallengeItem = item; //update item since this holder may have been recylced so that the correct feed item is used in click events if (item != null) { ChallengeName.Text = item.Name; ImageService.Instance.LoadUrl(item.IconImageURL).Into(ChallengeImage); } }
private async void startCompetition_Clicked(System.Object sender, System.EventArgs e) { try { bool isGoalNameEmpty = string.IsNullOrEmpty(goalNameEntry.Text); bool isGoalDescriptionEmpty = string.IsNullOrEmpty(goalDescriptionEntry.Text); bool isTargetCheckedAndEntryFilled = targetRB1.IsChecked && string.IsNullOrEmpty(goalTargetEntry.Text); bool isStepbyStepCheckedAndEntryFilled = targetRB2.IsChecked && (stepbystepPicker.SelectedIndex < 0); bool isWeeklyCheckedAndEntryFilled = repeatableRB2.IsChecked && repeatableRB21.IsChecked && (weekdayPicker.SelectedIndex < 0); bool isMonthlyCheckedAndEntryFilled = repeatableRB2.IsChecked && repeatableRB22.IsChecked && (dayOfMonthPicker.SelectedIndex < 0); if (isGoalNameEmpty || isGoalDescriptionEmpty || isTargetCheckedAndEntryFilled || isStepbyStepCheckedAndEntryFilled || isWeeklyCheckedAndEntryFilled || isMonthlyCheckedAndEntryFilled) { await DisplayAlert("Error", "All field needs to be entered", "Ok"); return; } challenge = new ChallengeModel() { OwnerId = App.loggedInUser.Id, CreatedDate = DateTime.Now }; await App.client.GetTable <ChallengeModel>().InsertAsync(challenge); var challenges = (await App.client.GetTable <ChallengeModel>().Where(c => c.OwnerId == App.loggedInUser.Id).ToListAsync()); challenges.Sort((x, y) => y.CreatedDate.CompareTo(x.CreatedDate)); challenge = challenges[0]; var challengedUsers = challengeCollectionView.SelectedItems; foreach (UserModel user in challengedUsers) { CreateGoal(user.Id, true, challenge.Id); } await DisplayAlert("Success", "Competition started and sent to selected team members", "Ok"); await Navigation.PopAsync(); } catch (Exception ex) { await DisplayAlert("Error", "Something went wrong, please try again", "Ok"); var properties = new Dictionary <string, string> { { "UpdateScoreboard", "startCompetition_Clicked" } }; Crashes.TrackError(ex, properties); } }
public async Task <IActionResult> Post([FromBody] ChallengeModel model) { var currentUserId = _userManager.GetUserId(User); if (model == null || string.IsNullOrEmpty(model.ReceivingPlayerId) || string.IsNullOrEmpty(model.SendingPlayerId) || model.SendingPlayerId != currentUserId) { return(BadRequest()); } if (model.SendingPlayerId == model.ReceivingPlayerId) { return(BadRequest()); } var sendingPlayer = _applicationUserService.GetUserById(model.SendingPlayerId ?? ""); var receivingPlayer = _applicationUserService.GetUserById(model.ReceivingPlayerId ?? ""); var challenge = new Challenge { SendingPlayerId = model.SendingPlayerId, ReceivingPlayerId = model.ReceivingPlayerId, SendingPlayer = sendingPlayer, ReceivingPlayer = receivingPlayer, Type = model.ChallengeType, SendingPlayerStatus = ChallengeStatus.Accepted, ReceivingPlayerStatus = ChallengeStatus.Pending, MatchId = model.MatchId }; var notification = new Notification { SendingPlayerId = model.SendingPlayerId, ReceivingPlayerId = model.ReceivingPlayerId, Status = NotificationStatus.Unread, Message = string.Format("{0} has challenged you to a match", sendingPlayer.PlayerName), Subject = "Challenge Request", HasOptions = true, Challenge = challenge }; _challengeService.AddChallenge(challenge); _notifactionService.AddNotification(notification); await _challengeService.SaveAsync(); await _notifactionService.SaveAsync(); return(Ok()); }
public ActionResult Challenges() { var userContext = _workContextService.GetAuthenticatedUser(); var model = new ChallengeModel(); foreach (var reto in _retoService.GetChallengesWithUserRelated(userContext.User.Id)) { model.DetailChallenges.Add(new DetailChallenge { Name = reto.Name, Goal = reto.Meta, MyProgress = _retoService.GetStepsForChallenge(reto.Id) }); } return(View(model)); }
public TwoFactorU2fResponseModel(User user, TwoFactorProvider provider, U2fRegistration registration = null) : base("twoFactorU2f") { if (user == null) { throw new ArgumentNullException(nameof(user)); } if (registration != null) { Challenge = new ChallengeModel(user, registration); } Enabled = provider?.Enabled ?? false; }
public void UpdateCellData(ChallengeModel item) { Crashlytics.Instance.Log("Challenges_ChallengesTableCell_UpdateCellData()"); try { SetupFonts(); _challengeTypeModel = new ChallengeTypeModel { TypeCode = (item as ChallengeModel).TypeCode, DisplayName = (item as ChallengeModel).TypeCodeDisplayName, ImageUrl = (item as ChallengeModel).IconImageURL }; int color = Convert.ToInt32(ChallengeModel.GetTypeCodeColor(item.TypeCode, item.TypeCodeDisplayName), 16); int r = (color & 0xff0000) >> 16; int g = (color & 0xff00) >> 8; int b = (color & 0xff); LeftSideView.BackgroundColor = UIColor.FromRGB(r, g, b); SeperatorView.BackgroundColor = UIColor.FromRGB(r, g, b); ChallengeName.Text = item.Name; LoadImages(_challengeTypeModel); ChallengeImage.Image = ChallengeImage.Image.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate); //ImgMapService.SetImage(item.IconImageURL, ChallengeImage); PointsText.Text = "+" + item.PointValue.ToString() + " pts"; ChallengeTime.Text = item.NextEventCountDown; ChallengeImage.TintColor = UIColor.LightGray; if (item.LockStatus) { ClosedImage.Hidden = false; ChellangeRightImage.Hidden = PointsText.Hidden = true; ClosedImage.Image = UIImage.FromBundle("lock_icon"); } else { var icon = UIImage.FromBundle("points-icon_white"); ClosedImage.Hidden = PointsText.Hidden = false; ClosedImage.Image = icon; } } catch (Exception e) { Crashlytics.Instance.Log($"Challenges_ChallengesTableCell_UpdateCellData() - {e.Message}"); } }
public async Task <CodeOutputModel> SubmitChallenge(ChallengeModel challenge) { var sw = new Stopwatch(); sw.Start(); var apiResult = await Client.PostAsJsonAsync($"api/challenge/submit", challenge); string result = await apiResult.Content.ReadAsStringAsync(); sw.Stop(); Console.WriteLine($"challenge submit too {sw.ElapsedMilliseconds}ms"); var output = JsonSerializer.Deserialize <CodeOutputModel>(result); return(output); }
public async Task SendOpenGraph(object source, ChallengeModel model, string message = null, byte[] data = null, Action <ChallengesFacebookShareResponseType> viewModelResponse = null, ShareTemplateModel shareTemplate = null, ShareResponseModel shareResponse = null) { ViewModelResponse = viewModelResponse; ShareDialog dialog = new ShareDialog(source as Activity); dialog.RegisterCallback((source as MainActivity).CallBackManager, this); if (shareTemplate == null || shareResponse == null) { await SL.Manager.RefreshShareTemplate(model.ShareTemplateURL, (response) => { ShareTemplate = response?.ShareTemplate; shareResponse = response; }); } else { ShareTemplate = shareTemplate; } OpenGraphWasTry = true; var openGraphBuilder = new ShareOpenGraphObject.Builder(); openGraphBuilder.PutString("og:type", "object"); openGraphBuilder.PutString("og:title", string.IsNullOrEmpty(ShareTemplate?.PostTitle) ? ShareTemplate?.PostHref : ShareTemplate.PostTitle); openGraphBuilder.PutString("og:description", string.IsNullOrEmpty(message) ? ShareTemplate?.PostDescription ?? " " : message); //openGraphBuilder.PutString("og:url", ShareTemplate?.PostHref ?? model.ShareImage); if (model != null && (model.FBShareType == "image" || !string.IsNullOrEmpty(model.ShareImage))) { openGraphBuilder.PutString("og:image", model.ShareImage); } if (model != null && (model.FBShareType == "link" || model.FBShareType == null)) { openGraphBuilder.PutString("og:url", ShareTemplate?.PostHref ?? model.ShareImage); } ShareOpenGraphObject openGraph = openGraphBuilder.Build(); ShareOpenGraphAction action = new ShareOpenGraphAction.Builder() .SetActionType("news.publishes") .PutObject("object", openGraph) .JavaCast <ShareOpenGraphAction.Builder>() .Build(); ShareOpenGraphContent contentOpenGraph = new ShareOpenGraphContent.Builder() .SetPreviewPropertyName("object") .SetAction(action) .Build(); dialog.Show(contentOpenGraph, ShareDialog.Mode.Web); //ShareDialog.Show(source as Activity, contentOpenGraph); }
private void DeleteChallengeButton_Click(object sender, RoutedEventArgs e) { // Get Challenge Index Button deleteButton = sender as Button; int selectedChallengeIndex = AllChallengesListBox.Items.IndexOf(deleteButton.DataContext); ChallengeModel chosenChallenge = (ChallengeModel)AllChallengesListBox.Items[selectedChallengeIndex]; // Delete Challenge From Database Database.DeleteChallenge(chosenChallenge.ID); // Refresh Challenges LoadAllChallenges(); // Confirmation Message AdminWindow.AdminWindowObject.MessagesSnackbar.MessageQueue.Enqueue("Challenge deleted successfully"); }
//private string ParseHTMLString() //{ // string pattern = @"font-family:\w{0,}\s{0,}\w{0,};font-size:\d{0,2}"; // string replacement = string.Format("font-family:SFProText-Regular;font-size:{0}", Math.Ceiling(SizeConstants.ScreenWidth * 0.058f)); // string result = Regex.Replace(Challenge.Desc, pattern, replacement); // return result; //} private void CheckStatus(ChallengeModel response) { if (response.Status == "Active") { return; } if (response.Status == "Pending") { SubmitButton.Hidden = true; return; } if (response.Status == "Complete") { SubmitButton.Hidden = true; return; } }
private void UnjoinChallengeButton_Unchecked(object sender, RoutedEventArgs e) { ToggleButton toggleButton = sender as ToggleButton; int selectedChallengeIndex = UncompletedJoinedChallengesListBox.Items.IndexOf(toggleButton.DataContext); ChallengeModel currentChallenge = (ChallengeModel)UncompletedJoinedChallengesListBox.Items[selectedChallengeIndex]; Database.UnjoinChallenge(UserWindow.signedInUser.ID, currentChallenge.ID); // Reloading Data context for JoinedChallengesListBox ChallengesViewModel joinedChallengesDataContext = new ChallengesViewModel(); joinedChallengesDataContext.JoinedChallengesViewModel(UserWindow.signedInUser.ID); UncompletedJoinedChallengesListBox.DataContext = joinedChallengesDataContext; // Refresh Challenges Page UserWindow.ChallengesPageObject.LoadAllChallengesCards(); }
private async Task <bool> GetChallengeOwner() { try { if (!string.IsNullOrEmpty(goal.ChallengeId)) { challenge = (await App.client.GetTable <ChallengeModel>().Where(c => c.Id == goal.ChallengeId).ToListAsync()).FirstOrDefault(); challengeOwner = (await App.client.GetTable <UserModel>().Where(u => u.Id == challenge.OwnerId).ToListAsync()).FirstOrDefault(); } return(true); } catch (Exception ex) { var properties = new Dictionary <string, string> { { "GoalDetailPage", "Get challenge owner" } }; Crashes.TrackError(ex, properties); return(false); } }
//challenge public int? CreateChallenge(Guid providerUserKey, ChallengeModel model) { using (var context = new greenMoneyEntities()) { var user = context.Users1.FirstOrDefault(u => u.Id == providerUserKey); if (user != null) { Challenges challenge = new Challenges(); Utils.CopyProperties(model, challenge); challenge.DateAdded = DateTime.Now; context.Challenges.Add(challenge); try { context.SaveChanges(); return challenge.Id; } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Class: {0}, Property: {1}, Error: {2}", validationErrors.Entry.Entity.GetType().FullName, validationError.PropertyName, validationError.ErrorMessage); } } return null; } } } return null; }
public void UpdateCellData(ChallengeTypeModel challengeType, bool isSelected, nfloat containerHeight) { Crashlytics.Instance.Log("ChallengeCollectionViewCell_UpdateCellData()"); try { if (challengeType == null) { return; } _challengeTypeModel = challengeType; ChallengeImage.TintColor = UIColor.Clear; int color = Convert.ToInt32(ChallengeModel.GetTypeCodeColor(challengeType.TypeCode, challengeType.DisplayName), 16); int r = (color & 0xff0000) >> 16; int g = (color & 0xff00) >> 8; int b = (color & 0xff); Background.BackgroundColor = UIColor.FromRGB(r, g, b); ChallengeName.Text = challengeType.DisplayName;//ChallengeModel.GetTypeCodeDisplayName(challengeType.TypeCode); LoadImages(challengeType); //else // ChallengeImage.Image = UIImage.FromBundle("insta-icon_white"); ChallengeProgressBar.Progress = challengeType.Total > 0 ? (float)challengeType.TotalComplete / (float)challengeType.Total : 0; ChallengeProgressText.Text = challengeType.TotalComplete + " of " + challengeType.Total; DidSelect = isSelected; UpdateItem(1.0f); if (isSelected) { UpdateItem(CellMultiplayer); } } catch (Exception e) { Crashlytics.Instance.Log($"ChallengeCollectionViewCell_UpdateCellData() {e.Message}"); throw; } }
public async Task <IActionResult> Edit(ChallengeModel challengeModel) { challengeModel.ApplicationUserId = _userManager.GetUserId(User); if (ModelState.IsValid) { try { _context.Update(challengeModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ChallengeModelExists(challengeModel.Id)) { return(NotFound()); } throw; } return(RedirectToAction(nameof(Index), new { contestId = challengeModel.ContestId })); } return(View(challengeModel)); }
public async Task <IActionResult> Create(ChallengeModel challengeModel) { try { if (ModelState.IsValid) { challengeModel.ApplicationUserId = _userManager.GetUserId(User); _context.Add(challengeModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index), new { contestId = challengeModel.ContestId })); } } catch (DbUpdateException e) { ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } ViewData["ContestId"] = challengeModel.ContestId; return(View(challengeModel)); }
public static LocalChallengeTypeModel ItemToLocalItem(ChallengeTypeModel item, IPlatformAssetService assetService, bool isSelected = false) { LocalChallengeTypeModel localItem = new LocalChallengeTypeModel() { Color = item.Color, DisplayName = item.DisplayName, Group = item.Group, ImageUrl = item.ImageUrl, Total = item.Total, TotalComplete = item.TotalComplete, TypeCode = item.TypeCode }; localItem.ItemState = isSelected ? Enums.ChallengesCollectionItemState.Selected : Enums.ChallengesCollectionItemState.Default; localItem.TotalCompleteText = item.TotalComplete + " of " + item.Total; localItem.Progress = (int)Math.Round(((double)item.TotalComplete / (double)item.Total) * 100); localItem.Color = "#" + ChallengeModel.GetTypeCodeColor(item.TypeCode, item.DisplayName); //localItem.Icon = LoadImages(item.TypeCode, item.DisplayName, assetService); localItem.Icon = new ChallengeIcon { Icon = ChallengesIconHelper.LoadImages(item.TypeCode, item.DisplayName, assetService), IconUrl = localItem.ImageUrl }; return(localItem); }
public static ChallengeModel ToModel(this IChallenge challenge) { var challengeModel = new ChallengeModel { Id = challenge.Id, Name = challenge.Name, Game = challenge.Game.Value, State = challenge.Timeline.State.Value, BestOf = challenge.BestOf, Entries = challenge.Entries, SynchronizedAt = challenge.SynchronizedAt, Timeline = challenge.Timeline.ToModel(), ScoringItems = challenge.Scoring.ToModel(), Participants = challenge.Participants.Select(participant => participant.ToModel()).ToList() }; foreach (var participant in challengeModel.Participants) { participant.Challenge = challengeModel; } return(challengeModel); }
public ChallengeModel CopyChallenge(int id) { using (var context = new greenMoneyEntities()) { Challenges challenge = context.Challenges.Single(x => x.Id == id); challenge.DateAdded = DateTime.Now; context.Challenges.Add(challenge); try { context.SaveChanges(); ChallengeModel challengeModel = new ChallengeModel(); Utils.CopyProperties(challenge, challengeModel); // challengeModel.AustraliaState = challenge.State; return challengeModel; } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Class: {0}, Property: {1}, Error: {2}", validationErrors.Entry.Entity.GetType().FullName, validationError.PropertyName, validationError.ErrorMessage); } } return null; } } }
public int? UpdateChallenge(Guid providerUserKey, ChallengeModel model) { using (var context = new greenMoneyEntities()) { var user = context.Users1.FirstOrDefault(u => u.Id == providerUserKey); var challenge = context.Challenges.FirstOrDefault(r => r.Id == model.Id); if (user != null && challenge != null) { Utils.CopyProperties(model, challenge); // challenge.State = model.AustraliaState; challenge.Owner_Id = user.Id; challenge.Instance_Id = user.Instance_Id; challenge.LogoImageId = model.LogoImageId; if (model.ProfileImages.Count > 0) { if (model.ProfileImages[0] != null && model.ProfileImages[0].FileName != null) { var upload = new UploadsRepository().UploadFile(providerUserKey.ToString(), model.ProfileImages[0]); challenge.ImageId1 = upload.UploadId; } else if (model.ImageId1 == null) { Uploads uploadOld = context.Uploads.SingleOrDefault(x => x.Id == challenge.ImageId1); if (uploadOld != null) { context.Uploads.Remove(uploadOld); challenge.ImageId1 = null; } } if (model.ProfileImages[1] != null && model.ProfileImages[1].FileName != null) { var upload = new UploadsRepository().UploadFile(providerUserKey.ToString(), model.ProfileImages[1]); challenge.ImageId2 = upload.UploadId; } else if (model.ImageId2 == null) { Uploads uploadOld = context.Uploads.SingleOrDefault(x => x.Id == challenge.ImageId2); if (uploadOld != null) { context.Uploads.Remove(uploadOld); challenge.ImageId2 = null; } } if (model.ProfileImages[2] != null && model.ProfileImages[2].FileName != null) { var upload = new UploadsRepository().UploadFile(providerUserKey.ToString(), model.ProfileImages[2]); challenge.ImageId3 = upload.UploadId; } else if (model.ImageId3 == null) { Uploads uploadOld = context.Uploads.SingleOrDefault(x => x.Id == challenge.ImageId3); if (uploadOld != null) { context.Uploads.Remove(uploadOld); challenge.ImageId3 = null; } } if (model.ProfileImages[3] != null && model.ProfileImages[3].FileName != null) { var upload = new UploadsRepository().UploadFile(providerUserKey.ToString(), model.ProfileImages[3]); challenge.ImageId4 = upload.UploadId; } else if (model.ImageId4 == null) { Uploads uploadOld = context.Uploads.SingleOrDefault(x => x.Id == challenge.ImageId4); if (uploadOld != null) { context.Uploads.Remove(uploadOld); challenge.ImageId4 = null; } } } try { context.SaveChanges(); return challenge.Id; } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Class: {0}, Property: {1}, Error: {2}", validationErrors.Entry.Entity.GetType().FullName, validationError.PropertyName, validationError.ErrorMessage); } } return null; } } } return null; }
public async void ShareFacebookChallenge(object source, ChallengeModel model, string message = null) { ShareTemplateModel shareTemplate = null; ShareResponseModel shareResponse = null; await SL.Manager.RefreshShareTemplate(model.ShareTemplateURL, (response) => { shareTemplate = response?.ShareTemplate; shareResponse = response; }); NSUrl url = new NSUrl(shareTemplate?.PostHref ?? model.ShareImage); ShareDialog dialog = new ShareDialog(); dialog.SetShouldFailOnDataError(true); dialog.FromViewController = source as UIViewController; dialog.SetDelegate(source as ISharingDelegate ?? new FBSharingDelegate()); if (string.IsNullOrEmpty(message) && model.FBShareType == "image") { UIImageView imageView = new UIImageView(); try { await ImageService.Instance.LoadUrl(model.ShareImage).IntoAsync(imageView); } catch (Exception) { try { await ImageService.Instance.LoadUrl(model.Image).IntoAsync(imageView); } catch (Exception) { } } dialog.SetShareContent(new SharePhotoContent() { Photos = new SharePhoto[] { SharePhoto.From(imageView.Image, true) } }); dialog.Mode = ShareDialogMode.Native; } else if (string.IsNullOrEmpty(message) && (model.FBShareType == "link" || model.FBShareType == null)) { ShareLinkContent contentLink = new ShareLinkContent(); if (string.IsNullOrEmpty(url?.AbsoluteString)) { new UIAlertView("Sharing Error", string.IsNullOrEmpty(shareResponse?.ResponseMessage) ? "Sorry. No url come from server" : shareResponse.ResponseMessage, source as IUIAlertViewDelegate, "Ok").Show(); return; } contentLink.SetContentUrl(url); dialog.SetShareContent(contentLink); dialog.Mode = ShareDialogMode.Web; } else { SendOpenGraph(source, model, message); return; } if (!dialog.CanShow()) { SendOpenGraph(source, model, message); return; } dialog.Show(); if (dialog.Mode == ShareDialogMode.Web) { StylishFbWebDialog(); } }
public ChallengeModel GetChallengeDetails(int id) { using (var context = new greenMoneyEntities()) { var challenge = context.Challenges.SingleOrDefault(x => x.Id == id); ChallengeModel model = new ChallengeModel(); Utils.CopyProperties(challenge, model); // model.AustraliaState = challenge.State; return model; } }
public ChallengesListModel GetChallenges(Guid providerUserKey, int page, int pageSize, int orderBy, int? status, int? category, string search) { using (var context = new greenMoneyEntities()) { var user = new UserRepository().GetUserById(providerUserKey); ChallengesListModel model = new ChallengesListModel(); var challenges = context.Challenges.Where(r => r.Instance_Id == user.Instance_Id) .Where(r => (category == null || category == 0) || r.ChallengeCategoryId == category) .Where(r => search == null || r.Name.Contains(search) || r.About.Contains(search)); DateTime now = DateTime.Now.Date; DateTime inWeek = DateTime.Now.Date.AddDays(7); switch (status) { case 1: challenges = challenges.Where(x => x.Display == false); break; case 2: challenges = challenges.Where(x => (x.Display == true) && (x.StartDate <= now || x.StartDate == null) && (x.EndDate >= now || x.EndDate == null)); break; case 3: challenges = challenges.Where(x => (x.Display == false) || (x.StartDate > now) || (x.EndDate < now)); break; case 4: challenges = challenges.Where(x => x.EndDate > now && x.EndDate <= inWeek); break; } model.NumChallenges = challenges.Count(); model.Page = page; model.NumPages = (int)Math.Ceiling((double)challenges.Count() / pageSize); if (pageSize == 0) pageSize = model.NumChallenges; List<ChallengeModel> list = new List<ChallengeModel>(); //IEnumerable<ChallengeModel> list = new IEnumerable<ChallengeModel>(); foreach (var challenge in challenges) { var challengeModel = new ChallengeModel(); Utils.CopyProperties(challenge, challengeModel); challengeModel.Participants = challenge.UserChallenges.Count(); // challengeModel.AustraliaState = challenge.State; if (challenge.ChallengeCategoryId != null) { challengeModel.ChallengeCategory = challenge.ChallengeCategories.Name; } else { challengeModel.ChallengeCategory = ""; } if ((challenge.StartDate <= DateTime.Now || challenge.StartDate == null) && (challenge.EndDate >= now || challenge.EndDate == null) && (challenge.Display == true)) { challengeModel.ChallengeStatus = "Active"; } else { challengeModel.ChallengeStatus = "Not active"; } list.Add(challengeModel); } switch (orderBy) { case 0: list = list.OrderByDescending(x => x.DateAdded).ToList(); break; case 1: list = list.OrderBy(x => x.DateAdded).ToList(); break; case 2: list = list.OrderByDescending(x => x.Participants).ToList(); break; case 3: list = list.OrderBy(x => x.EndDate).ToList(); break; case 4: list = list.OrderByDescending(x => x.Popularity).ToList(); break; } model.ChallengesList = list.AsEnumerable<ChallengeModel>().Skip((page - 1) * pageSize).Take(pageSize).ToList(); return model; } }
public int? UpdateChallenge(Guid providerUserKey, ChallengeModel model) { return new ChallengesAdminRepository().UpdateChallenge(providerUserKey, model); }
//challenge public int? CreateChallenge(Guid providerUserKey, ChallengeModel model) { using (var context = new greenMoneyEntities()) { var user = context.Users1.FirstOrDefault(u => u.Id == providerUserKey); if (user != null) { Challenges challenge = new Challenges(); Utils.CopyProperties(model, challenge); challenge.Owner_Id = user.Id; challenge.Instance_Id = user.Instance_Id; challenge.DateAdded = DateTime.Now; challenge.Popularity = 0; // challenge.State = model.AustraliaState; if (model.ProfileImages.Count > 0) { if (model.ProfileImages[0] != null && model.ProfileImages[0].FileName != null) { var upload = new UploadsRepository().UploadFile(providerUserKey.ToString(), model.ProfileImages[0]); challenge.ImageId1 = upload.UploadId; } if (model.ProfileImages[1] != null && model.ProfileImages[1].FileName != null) { var upload = new UploadsRepository().UploadFile(providerUserKey.ToString(), model.ProfileImages[1]); challenge.ImageId2 = upload.UploadId; } if (model.ProfileImages[2] != null && model.ProfileImages[2].FileName != null) { var upload = new UploadsRepository().UploadFile(providerUserKey.ToString(), model.ProfileImages[2]); challenge.ImageId3 = upload.UploadId; } if (model.ProfileImages[3] != null && model.ProfileImages[3].FileName != null) { var upload = new UploadsRepository().UploadFile(providerUserKey.ToString(), model.ProfileImages[3]); challenge.ImageId4 = upload.UploadId; } } context.Challenges.Add(challenge); try { context.SaveChanges(); return challenge.Id; } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Class: {0}, Property: {1}, Error: {2}", validationErrors.Entry.Entity.GetType().FullName, validationError.PropertyName, validationError.ErrorMessage); } } return null; } } } return null; }
public ActionResult Create(ChallengeModel model, HttpPostedFileBase contentImage, HttpPostedFileBase contentCoverImage, List <string> videoyoutube, string existingTags, string newTags) { ChallengeRepository objchallenge = new ChallengeRepository(this.SessionCustom); ContentManagement objcontent = new ContentManagement(this.SessionCustom, HttpContext); try { DateTime?currentEndDate = null; if (model.IContent.ContentId.HasValue) { objchallenge.Entity.ContentId = model.IContent.ContentId; objchallenge.LoadByKey(); currentEndDate = objchallenge.Entity.EndDate; objchallenge.Entity = new Domain.Entities.Challenge(); } objcontent.ContentImage = contentImage; objcontent.ContentCoverImage = contentCoverImage; objcontent.CollVideos = videoyoutube; this.SessionCustom.Begin(); model.IContent.LanguageId = CurrentLanguage.LanguageId; objcontent.ContentInsert(model.IContent); objchallenge.Entity = model.Challenge; objchallenge.Entity.ExistingTags = !string.Empty.Equals(existingTags) ? existingTags : null; objchallenge.Entity.NewTags = !string.Empty.Equals(newTags) ? newTags : null; if (objchallenge.Entity.ContentId != null) { objchallenge.Update(); bool reactivated = false; if (currentEndDate < DateTime.Now.Date && model.Challenge.EndDate >= DateTime.Now.Date) { reactivated = true; } if (reactivated) { ContentRepository content = new ContentRepository(SessionCustom); content.Entity.ContentId = model.Challenge.ContentId; content.LoadByKey(); Business.Utilities.Notification.StartReActivateProcess(content.Entity.Frienlyname, content.Entity.ContentId.Value, this.HttpContext, this.CurrentLanguage); } this.InsertAudit("Update", this.Module.Name + " -> " + model.IContent.Name); } else { if (!string.IsNullOrEmpty(Request.Form["TempFiles"])) { string[] files = Request.Form["TempFiles"].Split(','); if (files.Length > 0) { if (!Directory.Exists(Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\"))) { Directory.CreateDirectory(Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\")); } } foreach (var item in files) { string filep = Path.Combine(Server.MapPath("~"), @"Files\Images\" + Path.GetFileName(item)); if (System.IO.File.Exists(filep)) { string filedestin = Path.Combine(Server.MapPath("~"), @"Files\Images\" + Path.GetFileName(item)); System.IO.File.Move(filep, Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\" + Path.GetFileName(item))); } } } objchallenge.Entity.ContentId = objcontent.ObjContent.ContentId; objchallenge.Entity.Followers = 0; objchallenge.Insert(); ContentRepository content = new ContentRepository(SessionCustom); content.Entity.ContentId = model.Challenge.ContentId; content.LoadByKey(); ////EmailNotificationRepository emailNotification = new EmailNotificationRepository(SessionCustom); ////List<int> users = emailNotification.SendNewProcessNotification(); ////foreach (int userId in users) ////{ //// Business.Utilities.Notification.NewNotification(userId, Domain.Entities.Basic.EmailNotificationType.NEW_PROCESS, null, null, string.Concat("/", content.Entity.Frienlyname), content.Entity.ContentId, content.Entity.ContentId.Value, null, null, null, this.SessionCustom, this.HttpContext, this.CurrentLanguage); ////} Business.Utilities.Notification.StartNewProcess(content.Entity.Frienlyname, content.Entity.ContentId.Value, this.HttpContext, this.CurrentLanguage); this.InsertAudit("Insert", this.Module.Name + " -> " + model.IContent.Name); } this.SessionCustom.Commit(); } catch (Exception ex) { SessionCustom.RollBack(); Utils.InsertLog( this.SessionCustom, "Error" + this.Module.Name, ex.Message + " " + ex.StackTrace); } if (Request.Form["GetOut"] == "0") { return(this.RedirectToAction("Index", "Content", new { mod = Module.ModulId })); } else { return(this.RedirectToAction("Detail", "Challenge", new { mod = Module.ModulId, id = objchallenge.Entity.ContentId })); } }
public ActionResult Create(CreateChallengeViewModel model, string saveAndPreviewButton, string saveAndExitButton) { LayoutViewModel.ActiveLink = Links.CreateChallenge; var membershipUser = Membership.GetUser(); if (membershipUser != null && membershipUser.ProviderUserKey != null) { if (LayoutViewModel.IsCouncil) { if (ModelState.IsValid) { ChallengeModel challengeModel = new ChallengeModel(); Utils.CopyProperties(model, challengeModel); if (model.LogoPhoto != null && model.LogoPhoto.ContentLength > 0) { MemoryStream target = new MemoryStream(); model.LogoPhoto.InputStream.CopyTo(target); byte[] data = target.ToArray(); UploadModel uploadModel = new UploadModel { ContentType = model.LogoPhoto.ContentType, Contents = data, FileName = model.LogoPhoto.FileName }; UploadModel upload = new UploadService().UploadFile(membershipUser.ProviderUserKey.ToString(), uploadModel); challengeModel.LogoImageId = upload.UploadId; } if (model.ProfileImage != null) { List<UploadModel> profileImages = new List<UploadModel>(); for (var i = 0; i < 4; i++) { var image = model.ProfileImage[i]; UploadModel uploadModel = new UploadModel(); if (image != null) { MemoryStream target = new MemoryStream(); image.InputStream.CopyTo(target); byte[] data = target.ToArray(); uploadModel.ContentType = image.ContentType; uploadModel.Contents = data; uploadModel.FileName = image.FileName; } profileImages.Add(uploadModel); } challengeModel.ProfileImages = profileImages; } // rewardModel.PartnerEmail = model.PartnerEmail ?? membershipUser.Email; if (model.StartDate == DateTime.MinValue) { challengeModel.StartDate = null; } if (model.EndDate == DateTime.MinValue) { challengeModel.EndDate = null; } if (model.Points == null) { challengeModel.Points = 0; } int? challengeId; if (model.IsUpdate) { challengeId = new ChallengesAdminService().UpdateChallenge((Guid)membershipUser.ProviderUserKey, challengeModel); } else { challengeId = new ChallengesAdminService().CreateChallenge((Guid)membershipUser.ProviderUserKey, challengeModel); } if (challengeId != null) { //if (rewardModel.State == (int)RewardState.WaitingApproval) //{ // SendRewardSubmitEmail(rewardModel); //} } else { ModelState.AddModelError("", "Unable to save changes to database"); ViewModelHelper.SetDefaultsForChallengeViewModel(model, membershipUser); return View(model); } //if (saveAndApproveButton != null) //{ // return RedirectToAction("Create", new { id = rewardId, approve = true }); //} if (saveAndExitButton != null) { return RedirectToAction("Index"); } if (saveAndPreviewButton != null) { // redirect to Challenge page return RedirectToAction("Details", "Challenges", new { id = challengeId }); } return RedirectToAction("Create", new { id = challengeId }); } ViewModelHelper.SetDefaultsForChallengeViewModel(model, membershipUser); if (model.IsInitialRegistrationStep) { LayoutViewModel.HideTopWrapperMenu = true; } return View(model); } else return RedirectToAction("Index", "Home"); } else return RedirectToAction("Index", "Home"); }
public List<ChallengeModel> GetChallenges(string userId, int instanceId) { using (var context = new greenMoneyEntities()) { //used challenges that shouldnt be shown var myCompletedChallenges = (from uc in context.UserChallenges join c in context.Challenges on uc.ChallengeId equals c.Id where uc.UserId == new Guid(userId) && uc.PointsClaimed == true && SqlFunctions.GetDate() < (c.ParticipationFrequencyId == 1 ? SqlFunctions.DateAdd("YEAR", 100, uc.Issued) : c.ParticipationFrequencyId == 2 ? SqlFunctions.DateAdd("DAY", 7, uc.Issued) : c.ParticipationFrequencyId == 3 ? SqlFunctions.DateAdd("MONTH", 1, uc.Issued) : SqlFunctions.DateAdd("DAY", -1, SqlFunctions.GetDate())) select c); // all challenges for instance id var query = (from c in context.Challenges where (c.Instance.Id == instanceId) && (c.StartDate < SqlFunctions.GetDate() || c.StartDate == null) && (c.EndDate > SqlFunctions.GetDate() || c.EndDate == null) && (c.Display) select c); var list = new List<ChallengeModel>(); // iz rezultata drugog upita se izbacuje rezultat prvog i puni lista koja se dalje koristi za viewmodel. Ovde je sada kompletna lista challenga minus već korišćeni sa zabranom daljeg korišćenja. foreach (var challenge in query.Except(myCompletedChallenges).ToList()) { var model = new ChallengeModel(); Utils.CopyProperties(challenge, model); var userChallenge = context.UserChallenges.SingleOrDefault( x => x.ChallengeId == challenge.Id && x.UserId == new Guid(userId)); var exists = CheckIfInMyChallenges(userId, challenge.Id); model.ChallengeState = userChallenge != null && userChallenge.PointsClaimed.HasValue && userChallenge.PointsClaimed.Value ? ChallengeState.Completed : exists ? ChallengeState.Active : ChallengeState.NotAdded; var firstOrDefault = context.ChallengeCategories.FirstOrDefault(x => x.Id == challenge.ChallengeCategoryId); if (firstOrDefault != null) model.ChallengeCategoryShortName = firstOrDefault .ShortName; list.Add(model); } return list; } }
public ChallengeModel GetChallengeDetails(int id) { using (var context = new greenMoneyEntities()) { var challenge = context.Challenges.SingleOrDefault(x => x.Id == id); var model = new ChallengeModel(); if (challenge != null) Utils.CopyProperties(challenge, model); return model; } }
public static LocalChallengeModel ItemToLocalItem(ChallengeModel item, string sectionName, bool sectionHidden, IPlatformAssetService assetService) { LocalChallengeModel localItem = new LocalChallengeModel() { AllowUserCompletion = item.AllowUserCompletion, AnswerList = item.AnswerList, AutoUnlockDate = item.AutoUnlockDate, AvailabilityDate = item.AvailabilityDate, ChallengeDetailsURL = item.ChallengeDetailsURL, CollateralReview = item.CollateralReview, CompletedCount = item.CompletedCount, CompPointValue = item.CompPointValue, Desc = item.Desc, DisallowSharing = item.DisallowSharing, EffectiveEndDate = item.EffectiveEndDate, EffectiveStartDate = item.EffectiveStartDate, FBShareType = item.FBShareType, Group = item.Group, IconImageURL = item.IconImageURL, ID = item.ID, Image = item.Image, ImageLowRes = item.ImageLowRes, InstaCaption = item.InstaCaption, InstaURL = item.InstaURL, InviteToChallengeTemplateURL = item.InviteToChallengeTemplateURL, IsCommentReq = item.IsCommentReq, IsEventAttendReq = item.IsEventAttendReq, IsFixedContent = item.IsFixedContent, IsGuestList = item.IsGuestList, IsLikeReq = item.IsLikeReq, IsReshareReq = item.IsReshareReq, IsReviewReq = item.IsReviewReq, IsSurvey = item.IsSurvey, LeaderBoardList = item.LeaderBoardList, LocationLat = item.LocationLat, LocationLong = item.LocationLong, LockIndicatorImageURL = item.LockIndicatorImageURL, LockReason = item.LockReason, LockStatus = item.LockStatus, MinStars = item.MinStars, MinTags = item.MinTags, MulipleShops = item.MulipleShops, Name = item.Name, PointIconURL = item.PointIconURL, PointsPerDollar = item.PointsPerDollar, PointsPerInstance = item.PointsPerInstance, PointValue = item.PointValue, Question = item.Question, RadiusMeters = item.RadiusMeters, SecondsUntilExpire = item.SecondsUntilExpire, SecondsUntilUnlock = item.SecondsUntilUnlock, SelectAnswerID = item.SelectAnswerID, Sequence = item.Sequence, ShareImage = item.ShareImage, ShareTemplateURL = item.ShareTemplateURL, SmallImageURL = item.SmallImageURL, Status = item.Status, Subtitle = item.Subtitle, TargetCount = item.TargetCount, TargetObjectId = item.TargetObjectId, TargetObjectURL = item.TargetObjectURL, templateDiscountAmount = item.templateDiscountAmount, templateDiscountNum = item.templateDiscountNum, templateDiscountType = item.templateDiscountType, templateDiscountUse = item.templateDiscountUse, templateEndOffset = item.templateEndOffset, templateName = item.templateName, templateStartOffset = item.templateStartOffset, TypeCode = item.TypeCode, TypeCodeDisplayName = item.TypeCodeDisplayName, UpdateAll = item.UpdateAll, UseDefaultCodes = item.UseDefaultCodes, UsePointsPerDollar = item.UsePointsPerDollar, UseTeamCodes = item.UseTeamCodes }; localItem.Color = "#" + ChallengeModel.GetTypeCodeColor(item.TypeCode, item.TypeCodeDisplayName); localItem.PointsText = "+" + item.PointValue.ToString() + " pts"; localItem.SectionHidden = sectionHidden; localItem.SectionName = sectionName; localItem.Icon = new ChallengeIcon { Icon = ChallengesIconHelper.LoadImages(item.TypeCode, item.TypeCodeDisplayName, assetService), IconUrl = localItem.IconImageURL }; return(localItem); }
public Task <ChallengeModel> UpdateMembershipAsync(ChallengeModel challengeModel) { throw new NotImplementedException(); }
public async void SendOpenGraph(object source, ChallengeModel model, string message = null) { ShareTemplateModel shareTemplate = null; ShareResponseModel shareResponse = null; await SL.Manager.RefreshShareTemplate(model.ShareTemplateURL, (response) => { shareTemplate = response?.ShareTemplate; shareResponse = response; }); NSUrl url = new NSUrl(shareTemplate?.PostHref ?? model.ShareImage); if (string.IsNullOrEmpty(url?.AbsoluteString)) { new UIAlertView("Sharing Error", string.IsNullOrEmpty(shareResponse?.ResponseMessage) ? "Sorry. No url come from server" : shareResponse.ResponseMessage, source as IUIAlertViewDelegate, "Ok").Show(); return; } ShareDialog dialog = new ShareDialog(); dialog.SetShouldFailOnDataError(true); dialog.FromViewController = source as UIViewController; dialog.SetDelegate(source as ISharingDelegate ?? new FBSharingDelegate()); NSString[] keys; NSObject[] objects; string imgUrl = null; try { if (!string.IsNullOrEmpty(model.ShareImage)) { await ImageService.Instance.LoadUrl(model.ShareImage).IntoAsync(new UIImageView()); imgUrl = model.ShareImage; } } catch (Exception) { } if (string.IsNullOrEmpty(imgUrl)) { keys = new NSString[] { new NSString("og:type"), new NSString("og:url"), new NSString("og:title"), new NSString("og:description"), }; objects = new NSObject[] { NSObject.FromObject("article"), NSObject.FromObject(url), NSObject.FromObject(string.IsNullOrEmpty(shareTemplate?.PostTitle) ? url.AbsoluteString : shareTemplate.PostTitle), NSObject.FromObject(string.IsNullOrEmpty(message) ? shareTemplate?.PostDescription ?? " " : message), }; } else { keys = new NSString[] { new NSString("og:type"), new NSString("og:url"), new NSString("og:title"), new NSString("og:description"), new NSString("og:image"), }; objects = new NSObject[] { NSObject.FromObject("article"), NSObject.FromObject(url), NSObject.FromObject(string.IsNullOrEmpty(shareTemplate?.PostTitle) ? url.AbsoluteString : shareTemplate.PostTitle), NSObject.FromObject(string.IsNullOrEmpty(message) ? shareTemplate?.PostDescription ?? " " : message), NSObject.FromObject(imgUrl), }; } var propesties = new NSDictionary <NSString, NSObject>(keys, objects); var openGraph = ShareOpenGraphObject.ObjectWithProperties(propesties); var action = ShareOpenGraphAction.Action("news.publishes", openGraph, "article"); var contentOpenGraph = new ShareOpenGraphContent { Action = action, PreviewPropertyName = "article" }; dialog.SetShareContent(contentOpenGraph); dialog.Mode = ShareDialogMode.Web; dialog.Show(); if (dialog.Mode == ShareDialogMode.Web) { StylishFbWebDialog(); } }