public string CreateNonce(BidPart bid, TimeSpan delay) { var challengeToken = new XElement("n", new XAttribute("c", bid.Id), new XAttribute("v", _clock.UtcNow.ToUniversalTime().Add(delay).ToString(CultureInfo.InvariantCulture))).ToString(); var data = Encoding.UTF8.GetBytes(challengeToken); return(Convert.ToBase64String(_encryptionService.Encode(data))); }
private BidEntry CreateBidEntry(BidPart item) { return(new BidEntry { Bid = item.Record, BidedOn = _bidService.GetBidedContent(item.BidedOn), IsChecked = false, IsHeighest = _bidService.IsHeighestBid(item.Record.Id) }); }
private string CreateProtectedUrl(string action, BidPart part) { var workContext = _workContextAccessor.GetContext(); if (workContext.HttpContext != null) { var url = new UrlHelper(workContext.HttpContext.Request.RequestContext); return url.AbsoluteAction(action, "Bid", new {area = "Devq.Bids", nonce = _bidService.CreateNonce(part, TimeSpan.FromDays(7))}); } return null; }
private string CreateProtectedUrl(string action, BidPart part) { var workContext = _workContextAccessor.GetContext(); if (workContext.HttpContext != null) { var url = new UrlHelper(workContext.HttpContext.Request.RequestContext); return(url.AbsoluteAction(action, "Bid", new { area = "Devq.Bids", nonce = _bidService.CreateNonce(part, TimeSpan.FromDays(7)) })); } return(null); }
public bool CanCreateBid(BidPart bidPart) { if (bidPart == null) { return(false); } var bidsPart = GetContainer(bidPart); if (bidsPart == null) { return(false); } var settings = bidsPart.TypePartDefinition.Settings.GetModel <BidsPartSettings>(); if (!bidsPart.BidsActive) { return(false); } if (bidsPart.BidsDisabled) { return(false); } if (settings.MustBeAuthenticated && _orchardServices.WorkContext.CurrentUser == null) { return(false); } if (bidPart.BidPrice < bidsPart.MinimumBidPrice) { return(false); } if (!CanStillBidOn(bidsPart)) { return(false); } return(true); }
public void SendNotificationEmail(BidPart bidPart) { try { var bidedOn = _orchardServices.ContentManager.Get(bidPart.BidedOn); if (bidedOn == null) { return; } var owner = bidedOn.As <CommonPart>().Owner; if (owner == null) { return; } var template = _shapeFactory.Create("Template_Bid_Notification", Arguments.From(new { ContentItem = bidedOn, BidPart = bidPart, BidUrl = CreateUrl(bidedOn), })); var parameters = new Dictionary <string, object> { { "Subject", T("Bid notification").Text }, { "Body", _shapeDisplay.Display(template) }, { "Recipients", owner.Email } }; _messageService.Send("Email", parameters); } catch (Exception e) { Logger.Error(e, "An unexpected error occured while sending a notification email"); } }
public void SendNotificationEmail(BidPart bidPart) { try { var bidedOn = _orchardServices.ContentManager.Get(bidPart.BidedOn); if (bidedOn == null) { return; } var owner = bidedOn.As<CommonPart>().Owner; if (owner == null) { return; } var template = _shapeFactory.Create("Template_Bid_Notification", Arguments.From(new { ContentItem = bidedOn, BidPart = bidPart, BidUrl = CreateUrl(bidedOn), })); var parameters = new Dictionary<string, object> { {"Subject", T("Bid notification").Text}, {"Body", _shapeDisplay.Display(template)}, {"Recipients", owner.Email} }; _messageService.Send("Email", parameters); } catch (Exception e) { Logger.Error(e, "An unexpected error occured while sending a notification email"); } }
public bool CanCreateBid(BidPart bidPart) { if (bidPart == null) { return false; } var bidsPart = GetContainer(bidPart); if (bidsPart == null) { return false; } var settings = bidsPart.TypePartDefinition.Settings.GetModel<BidsPartSettings>(); if (!bidsPart.BidsActive) { return false; } if (bidsPart.BidsDisabled) { return false; } if (settings.MustBeAuthenticated && _orchardServices.WorkContext.CurrentUser == null) { return false; } if (bidPart.BidPrice < bidsPart.MinimumBidPrice) { return false; } if (!CanStillBidOn(bidsPart)) { return false; } return true; }
public decimal GetMinimumBidPrice(BidPart bidPart) { var bidsPart = GetContainer(bidPart); return bidsPart.MinimumBidPrice; }
public BidsPart GetContainer(BidPart bidPart) { return _orchardServices.ContentManager.Get<BidsPart>(bidPart.BidedOn); }
public string CreateNonce(BidPart bid, TimeSpan delay) { var challengeToken = new XElement("n", new XAttribute("c", bid.Id), new XAttribute("v", _clock.UtcNow.ToUniversalTime().Add(delay).ToString(CultureInfo.InvariantCulture))).ToString(); var data = Encoding.UTF8.GetBytes(challengeToken); return Convert.ToBase64String(_encryptionService.Encode(data)); }
public decimal GetMinimumBidPrice(BidPart bidPart) { var bidsPart = GetContainer(bidPart); return(bidsPart.MinimumBidPrice); }
public BidsPart GetContainer(BidPart bidPart) { return(_orchardServices.ContentManager.Get <BidsPart>(bidPart.BidedOn)); }