public PointItemVM(PointBundle bundle) { _bundle = bundle; if (bundle == null) { throw new ArgumentNullException(nameof(bundle)); } Id = bundle.Id; Name = bundle.Name; Address = bundle.Address; WorkTime = bundle.WorkTime; Distance = bundle.Distance; Phone = bundle.Phone; AdditionalInfo = bundle.Info; if (bundle.Latitude > 0 && bundle.Longitude > 0) { Coordinates = new Coordinates { Latitude = bundle.Latitude, Longitude = bundle.Longitude }; } }
//[System.AttributeUsage(System.AttributeTargets.All)] //public sealed class RedeemValidatorAttribute : ValidationAttribute //{ // protected override ValidationResult IsValid(object value, ValidationContext validationContext) // { // var val = (decimal)value; // var validValues = new[] { 1000M }; // if (validValues.Contains(val)) // { // return ValidationResult.Success; // } // return new ValidationResult(ErrorMessage); // } //} public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { try { PointBundle.Parse(Points); } catch (ArgumentException) { return(new[] { new ValidationResult("Invalid amount") }); } return(new[] { ValidationResult.Success }); //foreach (var field in typeof(PointBundle).GetFields(BindingFlags.Public | BindingFlags.Static)) //{ // if (field.IsLiteral) // { // continue; // } // var bundle = (PointBundle)field.GetValue(null); // if (bundle.Amount != Amount) // { // yield return new ValidationResult("Invalid amount"); // } //} }
public static GenerateSale BuyTokens(PointBundle price, string saleReturnUrl, string sellerId) { return(new GenerateSale() { CaptureBuyer = 0, SalePrice = (price.Price * 100), SaleReturnUrl = saleReturnUrl, SellerPaymeId = sellerId, ProductName = "עבור קניית נקודות בספיטבול" }); }
public PointItemVM(Point model) { _bundle = new PointBundle(model, NavigationType.PresentModal); if (model == null) { throw new ArgumentNullException(nameof(model)); } Id = model.Id; Name = model.Name; Address = model.Address; WorkTime = model.WorkTime; Distance = model.Distance; Phone = model.Phone; AdditionalInfo = model.AdditionalInfo; Coordinates = model.Coordinates; }
public async Task <SaleResponse> BuyTokensAsync(BuyPointsRequest model, CancellationToken token) { var user = await _userManager.GetUserAsync(User); var urlReturn = Url.RouteUrl(HomeController.PaymeCallbackRouteName2, new { userId = user.Id, points = model.Points }, "https"); var result = await _payment.Value.BuyTokens(PointBundle.Parse(model.Points), urlReturn, token); var saleUrl = new UriBuilder(result.SaleUrl); saleUrl.AddQuery(new NameValueCollection() { ["first_name"] = user.FirstName, ["last_name"] = user.LastName, ["phone"] = user.PhoneNumber, ["email"] = user.Email, }); return(new SaleResponse(saleUrl.Uri)); }
public void NavigateToPointAdditionalInfo(PointBundle bundle) { NavigateTo <IPointAdditionalInfoVM>(bundle); }
public async Task <GenerateSaleResponse> BuyTokens(PointBundle price, string successRedirect, CancellationToken token) { var generateSale = GenerateSale.BuyTokens(price, successRedirect, _credentials.SellerId); return(await GenerateSaleAsync(token, generateSale)); }
protected virtual void InitFromBundle(PointBundle deliveryPointBundle) { Item = new PointItemVM(deliveryPointBundle); VmNavigationType = deliveryPointBundle.NavigationType; }