public void ValidationSummary_IncludesErrorsThatAreNotPartOfMetadata()
        {
            // Arrange
            var expected = "<div class=\"HtmlEncode[[validation-summary-errors]]\" data-valmsg-summary=\"HtmlEncode[[true]]\"><ul>" +
                           "<li>HtmlEncode[[This is an error for Property2.]]</li>" + Environment.NewLine +
                           "<li>HtmlEncode[[This is another error for Property2.]]</li>" + Environment.NewLine +
                           "<li>HtmlEncode[[The value '' is not valid for Property2.]]</li>" + Environment.NewLine +
                           "<li>HtmlEncode[[This is an error for Property3.OrderedProperty3.]]</li>" + Environment.NewLine +
                           "<li>HtmlEncode[[This is an error for Property3.OrderedProperty2.]]</li>" + Environment.NewLine +
                           "<li>HtmlEncode[[This is an error for Property3.Property2.]]</li>" + Environment.NewLine +
                           "<li>HtmlEncode[[This is an error for Property3.]]</li>" + Environment.NewLine +
                           "<li>HtmlEncode[[This is an error for the model root.]]</li>" + Environment.NewLine +
                           "<li>HtmlEncode[[This is another error for the model root.]]</li>" + Environment.NewLine +
                           "<li>HtmlEncode[[non-existent-error1]]</li>" + Environment.NewLine +
                           "<li>HtmlEncode[[non-existent-error2]]</li>" + Environment.NewLine +
                           "<li>HtmlEncode[[non-existent-error3]]</li>" + Environment.NewLine +
                           "</ul></div>";
            var model = new ValidationModel();
            var html  = DefaultTemplatesUtilities.GetHtmlHelper(model);

            AddMultipleErrors(html.ViewData.ModelState);
            html.ViewData.ModelState.AddModelError("non-existent-property1", "non-existent-error1");
            html.ViewData.ModelState.AddModelError("non.existent.property2", "non-existent-error2");
            html.ViewData.ModelState.AddModelError("non.existent[0].property3", "non-existent-error3");

            // Act
            var result = html.ValidationSummary(
                excludePropertyErrors: false,
                message: null,
                htmlAttributes: null,
                tag: null);

            // Assert
            Assert.Equal(expected, HtmlContentUtilities.HtmlContentToString(result));
        }
        public async Task <IActionResult> deleteEvent([FromBody] DeleteEventRequest request)
        {
            try
            {
                ValidationModel validationModel = new ValidationModel();
                if (request.uidReserva == Guid.Empty)
                {
                    validationModel.ValidationResults.Add(new ValidationResult("-1", new[] { "falta parametro uidReserva" }));
                    return(new BadRequestObjectResult(validationModel));
                }
                else
                {
                    var retorno = await _reservasSrv.RegistroDetele(request.uidReserva);

                    if (retorno != "0")
                    {
                        validationModel.ValidationResults.Add(new ValidationResult("-1", new[] { retorno }));
                        return(new BadRequestObjectResult(validationModel));
                    }
                    else
                    {
                        return(Ok(new ApiOkResponse("OK")));
                    }
                }
            }
            catch (CError ce)
            {
                throw ce;
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
        private void GenerateRules(ValidationModel model, Type propertyType, string prefix = "")
        {
            var validatorsForProperty = ValidatorsResolver.GetAllForType(propertyType);

            if (!validatorsForProperty.Any())
            {
                return;
            }

            foreach (var validatorForProperty in validatorsForProperty)
            {
                GenerateChildRules(model, validatorForProperty, prefix);
            }

            foreach (var nestedPropertyInfo in propertyType.GetProperties())
            {
                if (nestedPropertyInfo.PropertyType.IsValueType)
                {
                    GenerateValueTypesRules(model, nestedPropertyInfo, prefix);
                }
                else if (nestedPropertyInfo.PropertyType.IsGenericType)
                {
                    var genericType = nestedPropertyInfo.PropertyType.GetGenericArguments().First();
                    GenerateRules(model, genericType, nestedPropertyInfo.Name.ToPrefix(prefix));
                }
                else if (nestedPropertyInfo.PropertyType.IsClass)
                {
                    GenerateRules(model, nestedPropertyInfo.PropertyType, nestedPropertyInfo.Name.ToPrefix(prefix));
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Creates contact record in database
        /// </summary>
        private void CreateContactButton_Click(object sender, EventArgs e)
        {
            ContactModel    p         = new ContactModel();
            ValidationModel validated = new ValidationModel();

            p.FirstName        = firstNameValue.Text;
            p.LastName         = lastNameValue.Text;
            p.BirthDate        = birthDateValue.Text;
            p.CellPhone        = cellPhoneValue.Text;
            p.HomePhone        = homePhoneValue.Text;
            p.OfficePhone      = officePhoneValue.Text;
            p.EmailAddress     = emailAddressValue.Text;
            p.StreetAddressOne = streetAddressOneValue.Text;
            p.StreetAddressTwo = streetAddressTwoValue.Text;
            p.City             = cityValue.Text;
            p.State            = stateValue.Text;
            p.ZipCode          = zipCodeValue.Text;

            validated = ValidationLogic.ValidateForm(p);

            if (validated.Result)
            {
                SqliteDataAccess.SaveContact(p);
                contactForm.ContactComplete(p);
                this.Close();
            }
            else
            {
                messageLbl.Visible = true;
                messageLbl.Text    = validated.Message;
            }
        }
        private void GenerateValueTypesRules(ValidationModel model, PropertyInfo nestedPropertyInfo, string prefix)
        {
            var valueTypeRuleMatches = _valueTypeMatchesFinder.GetMatches(nestedPropertyInfo.PropertyType);

            if (!valueTypeRuleMatches.Any())
            {
                return;
            }

            var property = _propertyResolver.GetPropertyName(prefix + nestedPropertyInfo.Name);
            var field    = model.GetOrCreateValidationProperty(property);

            foreach (var valueTypeRuleMatch in valueTypeRuleMatches)
            {
                var validationRule = _valueTypeRuleFactory.CreateRule(valueTypeRuleMatch);
                if (validationRule == null)
                {
                    continue;
                }
                if (!field.Rules.ContainsKey(validationRule.Name))
                {
                    field.Rules.Add(validationRule.Name, validationRule);
                }
            }
        }
        public SingleReportPurchaseViewModel(ValidationModel validation,
                                             Action <Uri> openUri,
                                             string runtimePlatform,
                                             AlertUtility alertUtility,
                                             MainThreadNavigator nav,
                                             IToastService toastService,
                                             IPurchasedReportService prService,
                                             IPurchasingService purchaseService,
                                             ICurrentUserService userCache,
                                             ICache <PurchasedReportModel> prCache,
                                             ILogger <SingleReportPurchaseViewModel> emailLogger)
        {
            _validation      = validation;
            _openUri         = openUri;
            _nav             = nav;
            _toastService    = toastService;
            _runtimePlatform = runtimePlatform;
            _userCache       = userCache;
            _purchaseService = purchaseService;
            _prService       = prService;
            _prCache         = prCache;
            _emailLogger     = emailLogger;
            _alertUtility    = alertUtility;

            SetViewState(validation);
        }
        public async Task <IActionResult> AddRecibos([FromBody] ReciboRequest request)
        {
            try
            {
                ValidationModel validationModel = new ValidationModel();
                var             retorno         = await _recibosSrv.AddRecibos(request);

                if (retorno.berror)
                {
                    validationModel.ValidationResults.Add(new ValidationResult("-1", new[] { retorno.msjError }));
                    return(new BadRequestObjectResult(validationModel));
                }
                else
                {
                    return(Ok(new ApiOkResponse("OK")));
                }
            }
            catch (CError ce)
            {
                throw ce;
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
Exemple #8
0
        private void SetVisualState(ValidationModel validation)
        {
            var freeTrial = false;

            try
            {
                freeTrial          = new[] { ValidationState.NoSubscriptionAndTrialValid, ValidationState.FreeReportValid }.Contains(validation.State);
                PurchaseButtonText = freeTrial ? "Start Your Free Trial" : "Purchase Subscription Plan";
                LegalText          = GetLegalJargon(validation);
            }
            catch { }
            try
            {
                ReportsDescVisible    = true;
                CostDescVisible       = true;
                AvgCostVisible        = true;
                PurchaseButtonEnabled = true;
            }
            catch { }
            if (freeTrial)
            {
                MarketingDescVisible = true;
                MarketingDescText    = $"One month free trial!";
                CostDescText         = $"${SubscriptionUtility.BasicPrice} per month after trial period ends";
            }
            else
            {
                MarketingDescVisible = false;
                CostDescText         = $"${SubscriptionUtility.BasicPrice} per month";
            }
            ReportsDescText = $"{SubscriptionUtility.BasicOrderCount} reports per month";
            AvgCostText     = $"Unlocks access to purchase additional reports at a reduced price of ${SubscriptionUtility.IndvReportBasicPrice} per report.";
        }
Exemple #9
0
        public override void OnException(HttpActionExecutedContext context)
        {
            _logger.WriteError(context.Exception, LogCategories);
            HttpResponseMessage           responseMessage = new HttpResponseMessage(HttpStatusCode.BadRequest);
            List <ValidationMessageModel> messages        = new List <ValidationMessageModel>();
            ValidationModel model          = new ValidationModel();
            int             validationCode = (int)DSWExceptionCode.Invalid;

            responseMessage.ReasonPhrase = null;
            responseMessage.StatusCode   = HttpStatusCode.BadRequest;
            if (context.Exception is DSWException)
            {
                DSWException ex = context.Exception as DSWException;

                messages.Add(new ValidationMessageModel()
                {
                    Message = ex.Message, MessageCode = (int)ex.ExceptionCode
                });
            }
            else
            {
                messages = FillRecursive(context.Exception, messages, validationCode);
            }

            model.ValidationCode     = validationCode;
            model.ValidationMessages = new ReadOnlyCollection <ValidationMessageModel>(messages);
            responseMessage.Content  = new StringContent(JsonConvert.SerializeObject(model, JsonSerializerConfig.SerializerSettings));

            context.Response = responseMessage;
        }
        public static SingleReportInfo GetSingleReportInfo(ValidationModel validation)
        {
            if (validation.Subscription == null)
            {
                return new SingleReportInfo()
                       {
                           Code  = INDV_REPORT_NO_SUB,
                           Price = IndvReportNoSubPrice
                       }
            }
            ;
            switch (validation.Subscription.SubscriptionType)
            {
            case SubscriptionType.Premium:
                return(new SingleReportInfo()
                {
                    Code = INDV_REPORT_PREMIUM,
                    Price = IndvReportPremiumPrice
                });

            case SubscriptionType.Enterprise:
                return(new SingleReportInfo()
                {
                    Code = INDV_REPORT_ENTERPRISE,
                    Price = IndvReportEnterprisePrice
                });

            default:
                return(new SingleReportInfo()
                {
                    Code = INDV_REPORT_BASIC,
                    Price = IndvReportBasicPrice
                });
            }
        }
        private void MockData(
            AttachmentBurial attachmentBurial = default,
            IEnumerable <AttachmentBurial> attachmentBurialList           = default,
            ValidationModel <AttachmentBurial> validationAttachmentBurial = default
            )
        {
            _fileHelper.Setup(x => x.SaveFile(It.IsAny <IFormFile>()))
            .ReturnsAsync(GetFileModelByAttachmentBurial(attachmentBurial));
            _fileHelper.Setup(x => x.SaveFileRange(It.IsAny <IList <IFormFile> >()))
            .ReturnsAsync(GetFileModelListByAttachmentBurial(attachmentBurialList));
            _fileHelper.Setup(x => x.DeleteFile(It.IsAny <string>()));

            _dataAttachmentBurial.Setup(x => x.GetAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(attachmentBurial);
            _dataAttachmentBurial.Setup(x => x.GetAllAsync(It.IsAny <CancellationToken>())).ReturnsAsync(attachmentBurialList);
            _dataAttachmentBurial.Setup(x => x.InsertAsync(It.IsAny <AttachmentBurial>(), It.IsAny <CancellationToken>())).ReturnsAsync(attachmentBurial);
            _dataAttachmentBurial.Setup(x => x.UpdateAsync(It.IsAny <AttachmentBurial>(), It.IsAny <CancellationToken>())).ReturnsAsync(attachmentBurial);
            _dataAttachmentBurial.Setup(x => x.DeleteAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>()));

            _attachmentBurialValidation.Setup(x => x.GetValidationAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(validationAttachmentBurial);
            _attachmentBurialValidation.Setup(x => x.InsertValidationAsync(It.IsAny <AttachmentBurial>(), It.IsAny <CancellationToken>())).ReturnsAsync(validationAttachmentBurial);
            _attachmentBurialValidation.Setup(x => x.UpdateValidationAsync(It.IsAny <AttachmentBurial>(), It.IsAny <CancellationToken>())).ReturnsAsync(validationAttachmentBurial);
            _attachmentBurialValidation.Setup(x => x.DeleteValidationAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(validationAttachmentBurial);

            _service = new AttachmentBurialService(_fileHelper.Object, _dataAttachmentBurial.Object, _attachmentBurialValidation.Object);
        }
        private string GetLegalJargon(ValidationModel validation)
        {
            string platformText = _runtimePlatform == Device.Android ? "Play Store" : "iTunes";
            var    costDesc     = $"${SubscriptionUtility.IndvReportNoSubPrice.ToString()}";

            if (validation.Subscription != null)
            {
                var info = SubscriptionUtility.GetInfoFromSubType(validation.Subscription.SubscriptionType);
                switch (validation.Subscription.SubscriptionType)
                {
                case SubscriptionType.Premium:
                    costDesc = $"${SubscriptionUtility.IndvReportPremiumPrice.ToString()}";
                    break;

                case SubscriptionType.Enterprise:
                    costDesc = $"${SubscriptionUtility.IndvReportEnterprisePrice.ToString()}";
                    break;

                default:
                    costDesc = $"${SubscriptionUtility.IndvReportBasicPrice.ToString()}";
                    break;
                }
            }
            return($@"A {costDesc} purchase will be applied to your {platformText} account upon confirmation. " +
                   $@"For more information, ");
        }
        public ActionResult Verify(ValidationModel model)
        {
            try
            {
                var apiCaller = new ApiCaller(model.MerchantId, model.ApiKey, true);

                //Send the newly checkout data to Payson
                var data = apiCaller.Validate();
                return(Json(data, JsonRequestBehavior.AllowGet));
            }
            catch (WebException e)
            {
                var response = (HttpWebResponse)e.Response;

                string responseBody;

                using (var responseStream = response.GetResponseStream())
                {
                    if (responseStream == null)
                    {
                        throw new NullReferenceException("No response stream found.");
                    }

                    using (var reader = new StreamReader(responseStream))
                    {
                        responseBody = reader.ReadToEnd();
                    }
                }

                return(Json(new JavaScriptSerializer().Deserialize <object>(responseBody), JsonRequestBehavior.AllowGet));
            }
        }
        public IHttpActionResult CheckRoutes(ValidationModel model)
        {
            List <RouteModel> routeModel = new List <RouteModel>();

            var response = Utility.FilteredRoutes(Utility.isRouteSimilar(model), model.Distance);

            foreach (var item in response.Body)
            {
                RouteModel r = new RouteModel();

                r.RouteID   = item.ID_Route;
                r.RouteName = item.RouteName;
                foreach (var item2 in item.LocationList)
                {
                    LocationModel loc = new LocationModel();

                    loc.lat         = item2.Latitude;
                    loc.lng         = item2.Longitude;
                    loc.isMilestone = item2.isMilestone;

                    r.Coordinates.Add(loc);
                }
            }

            if (response.IsComplete())
            {
                return(Ok(routeModel));
            }
            else
            {
                return(BadRequest(response.Message));
            }
        }
        public void ValidationSummary_OrdersCorrectlyWhenElementsAreRemovedFromDictionary()
        {
            // Arrange
            var expected = "<div class=\"HtmlEncode[[validation-summary-errors]]\" data-valmsg-summary=\"HtmlEncode[[true]]\"><ul>" +
                           "<li>HtmlEncode[[New error for Property2.]]</li>" + Environment.NewLine +
                           "<li>HtmlEncode[[This is an error for Property3.OrderedProperty3.]]</li>" + Environment.NewLine +
                           "<li>HtmlEncode[[This is an error for Property3.Property2.]]</li>" + Environment.NewLine +
                           "<li>HtmlEncode[[This is an error for the model root.]]</li>" + Environment.NewLine +
                           "<li>HtmlEncode[[This is another error for the model root.]]</li>" + Environment.NewLine +
                           "</ul></div>";
            var model = new ValidationModel();
            var html  = DefaultTemplatesUtilities.GetHtmlHelper(model);

            AddMultipleErrors(html.ViewData.ModelState);
            html.ViewData.ModelState.RemoveAll <ValidationModel>(m => m.Property2);
            html.ViewData.ModelState.Remove <ValidationModel>(m => m.Property3);
            html.ViewData.ModelState.Remove <ValidationModel>(m => m.Property3.OrderedProperty2);
            html.ViewData.ModelState.AddModelError("Property2", "New error for Property2.");

            // Act
            var result = html.ValidationSummary(
                excludePropertyErrors: false,
                message: null,
                htmlAttributes: null,
                tag: null);

            // Assert
            Assert.Equal(expected, HtmlContentUtilities.HtmlContentToString(result));
        }
Exemple #16
0
        private void MockData(
            Burial burial = default,
            AttachmentBurial attachmentBurial = default,
            IEnumerable <Burial> burialList   = default,
            IEnumerable <AttachmentBurial> attachmentBurialList = default,
            ValidationModel <Burial> validationBurial           = default
            )
        {
            _dataBurial.Setup(x => x.GetAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(burial);
            _dataBurial.Setup(x => x.GetAllAsync(It.IsAny <CancellationToken>())).ReturnsAsync(burialList);
            _dataBurial.Setup(x => x.InsertAsync(It.IsAny <Burial>(), It.IsAny <CancellationToken>())).ReturnsAsync(burial);
            _dataBurial.Setup(x => x.UpdateAsync(It.IsAny <Burial>(), It.IsAny <CancellationToken>())).ReturnsAsync(burial);
            _dataBurial.Setup(x => x.DeleteAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>()));

            _dataAttachmentBurial.Setup(x => x.GetAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(attachmentBurial);
            _dataAttachmentBurial.Setup(x => x.GetAllAsync(It.IsAny <CancellationToken>())).ReturnsAsync(attachmentBurialList);
            _dataAttachmentBurial.Setup(x => x.InsertAsync(It.IsAny <AttachmentBurial>(), It.IsAny <CancellationToken>())).ReturnsAsync(attachmentBurial);
            _dataAttachmentBurial.Setup(x => x.UpdateAsync(It.IsAny <AttachmentBurial>(), It.IsAny <CancellationToken>())).ReturnsAsync(attachmentBurial);
            _dataAttachmentBurial.Setup(x => x.DeleteAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>()));

            _burialValidation.Setup(x => x.GetValidationAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(validationBurial);
            _burialValidation.Setup(x => x.InsertValidationAsync(It.IsAny <Burial>(), It.IsAny <CancellationToken>())).ReturnsAsync(validationBurial);
            _burialValidation.Setup(x => x.UpdateValidationAsync(It.IsAny <Burial>(), It.IsAny <CancellationToken>())).ReturnsAsync(validationBurial);
            _burialValidation.Setup(x => x.DeleteValidationAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(validationBurial);

            _service = new BurialService(_fileHelper.Object, _dataBurial.Object, _dataAttachmentBurial.Object, _burialValidation.Object);
        }
Exemple #17
0
        public ValidationModel ValidateBar(BarDTO barDTO)
        {
            var validationModel = new ValidationModel();

            if (barDTO == null)
            {
                validationModel.HasProperInputData = false;
            }
            if (barDTO.Name == string.Empty || barDTO.Name.Any(x => !char.IsLetter(x) && !char.IsWhiteSpace(x)))
            {
                validationModel.HasValidName = false;
            }
            if (barDTO.Name.Length < 2 || barDTO.Name.Length > 30)
            {
                validationModel.HasProperNameLength = false;
            }
            if (barDTO.Address.Length < 5 ||
                barDTO.Address.Length > 100 ||
                barDTO.Address == string.Empty)
            {
                validationModel.HasProperAddress = false;
            }
            if (barDTO.Phone.Length < 7 ||
                barDTO.Phone.Length > 20 ||
                barDTO.Phone == string.Empty ||
                !barDTO.Phone.Any(x => char.IsDigit(x)))
            {
                validationModel.HasProperPhone = false;
            }
            return(validationModel);
        }
        private void MockData(
            Form form = default,
            AttachmentForm attachmentForm = default,
            IEnumerable <Form> formList   = default,
            IEnumerable <AttachmentForm> attachmentFormList = default,
            ValidationModel <Form> validationForm           = default
            )
        {
            _dataForm.Setup(x => x.GetAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(form);
            _dataForm.Setup(x => x.GetAllAsync(It.IsAny <CancellationToken>())).ReturnsAsync(formList);
            _dataForm.Setup(x => x.InsertAsync(It.IsAny <Form>(), It.IsAny <CancellationToken>())).ReturnsAsync(form);
            _dataForm.Setup(x => x.UpdateAsync(It.IsAny <Form>(), It.IsAny <CancellationToken>())).ReturnsAsync(form);
            _dataForm.Setup(x => x.DeleteAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>()));

            _dataAttachmentForm.Setup(x => x.GetAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(attachmentForm);
            _dataAttachmentForm.Setup(x => x.GetAllAsync(It.IsAny <CancellationToken>())).ReturnsAsync(attachmentFormList);
            _dataAttachmentForm.Setup(x => x.InsertAsync(It.IsAny <AttachmentForm>(), It.IsAny <CancellationToken>())).ReturnsAsync(attachmentForm);
            _dataAttachmentForm.Setup(x => x.UpdateAsync(It.IsAny <AttachmentForm>(), It.IsAny <CancellationToken>())).ReturnsAsync(attachmentForm);
            _dataAttachmentForm.Setup(x => x.DeleteAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>()));

            _formValidation.Setup(x => x.GetValidationAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(validationForm);
            _formValidation.Setup(x => x.InsertValidationAsync(It.IsAny <Form>(), It.IsAny <CancellationToken>())).ReturnsAsync(validationForm);
            _formValidation.Setup(x => x.UpdateValidationAsync(It.IsAny <Form>(), It.IsAny <CancellationToken>())).ReturnsAsync(validationForm);
            _formValidation.Setup(x => x.DeleteValidationAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(validationForm);

            _service = new FormService(_fileHelper.Object, _dataForm.Object, _dataAttachmentForm.Object, _formValidation.Object);
        }
Exemple #19
0
 public PurchaseViewModel(IToastService toastService,
                          IPurchasingService purchaseService,
                          ICache <SubscriptionModel> subCache,
                          ISubscriptionService subService,
                          ICurrentUserService userCache,
                          MainThreadNavigator nav,
                          ValidationModel validationModel,
                          string runtimePlatform,
                          Action <BaseNavPageType> navigateFromMenu,
                          AlertUtility alertUtility,
                          Action <Uri> openUri)
 {
     _toastService         = toastService;
     _purchaseService      = purchaseService;
     _subCache             = subCache;
     _subService           = subService;
     _userCache            = userCache;
     _validationModel      = validationModel;
     _runtimePlatform      = runtimePlatform;
     _openUri              = openUri;
     _alertUtility         = alertUtility;
     _nav                  = nav;
     _navigateFromMenu     = navigateFromMenu;
     LegalLinkCommand      = new Command(() => _openUri(new Uri(Configuration.PrivacyPolicyUrl)));
     PurchaseButtonCommand = new Command(() => PurchaseButtonClicked());
     SetVisualState(validationModel);
 }
 public ManageSubscriptionViewModel(ValidationModel model,
                                    string runtimePlatform,
                                    Action <Uri> openUri,
                                    MainThreadNavigator nav,
                                    ILogger <ManageSubscriptionViewModel> logger,
                                    IPageFactory pageFactory)
 {
     _model           = model;
     _runtimePlatform = runtimePlatform;
     _openUri         = openUri;
     _nav             = nav;
     _logger          = logger;
     _pageFactory     = pageFactory;
     try
     {
         SubscriptionTypeLabel = "   " + _model.Subscription.SubscriptionType.ToString();
         RemainingOrdersLabel  = "   " + _model.RemainingOrders.ToString();
         PurchasedOrdersLabel  = "   " + _model.PurchasedReports?.Count.ToString();
         EndDateLabel          = "   " + _model.Subscription.EndDateTime.ToString("dddd, dd MMMM yyyy");
         GetMoreReportsLabel   = $"Purchase additional reports at a reduced price of ${SubscriptionUtility.GetSingleReportInfo(_model).Price} per report.";
         GetMoreReportsCommand = new Command(() => _nav.Push(_pageFactory.GetPage(PageType.SingleReportPurchase, _model)));
         var compName   = _runtimePlatform == Device.Android ? "Google" : "Apple";
         var supportUri = _runtimePlatform == Device.Android ? "https://support.google.com/googleplay/answer/7018481" :
                          "https://support.apple.com/en-us/HT202039#subscriptions";
         DisclaimerLabel  = $"NOTE: {compName} does not allow subscriptions to be cancelled through the app. This button will open a web browser with instructions on how to cancel from your device.";
         CancelSubCommand = new Command(() => _openUri(new Uri(supportUri)));
     }
     catch (Exception ex)
     {
         _logger.LogError($"Failed to load manage subscription page.", ex);
     }
 }
        public async Task <IActionResult> ConfirmEmail(ValidationModel param)
        {
            if (param.Username == null || param.Token == null)
            {
                return(BadRequest(new { Message = "Invalid parameters supplied" }));
            }
            var user = await manager.FindByNameAsync(param.Username);

            if (user != null)
            {
                var res = await manager.ConfirmEmailAsync(user, param.Token);

                if (res.Succeeded)
                {
                    var temp = await userService.EnableUser(param.Username);

                    if (temp.Success)
                    {
                        return(Ok(true));
                    }
                    else
                    {
                        return(BadRequest(false));
                    }
                }
                else
                {
                    return(BadRequest(false));
                }
            }
            else
            {
                return(null);
            }
        }
Exemple #22
0
 public MainWindow()
 {
     InitializeComponent();
     this.md5hash     = MD5.Create();
     this.md5Function = new RegisterModel();
     this.model       = new LoginModel();
     this.validModel  = new ValidationModel();
 }
Exemple #23
0
 public async Task <IActionResult> ValidationModelCreate(ValidationModel input)
 {
     if (!ModelState.IsValid)
     {
         return(View());
     }
     return(View());
 }
Exemple #24
0
 public registerWindow()
 {
     InitializeComponent();
     model      = new RegisterModel();
     validModel = new ValidationModel();
     md5Hash    = MD5.Create();
     db         = new UsersDataBase();
 }
Exemple #25
0
        public async Task <ValidationModel <IEnumerable <ConscriptionPlace> > > GetAllAsync(CancellationToken cancellationToken = default)
        {
            var validation = new ValidationModel <IEnumerable <ConscriptionPlace> >();

            validation.Result = await dataConscriptionPlace.GetAllAsync(cancellationToken);

            return(validation);
        }
        protected override void Arrange()
        {
            base.Arrange();
            this.ValidationModel = Container.Resolve <ValidationModel>();

            Assert.IsFalse(
                this.ValidationModel.ValidationResults.Any(v => v.Message == CollectionCountOneValidator.Message));
        }
        public async Task <ValidationModel <IEnumerable <Burial> > > GetAllAsync(CancellationToken cancellationToken = default)
        {
            var validation = new ValidationModel <IEnumerable <Burial> >();

            validation.Result = await dataBurial.GetAllAsync(cancellationToken);

            return(validation);
        }
Exemple #28
0
        public void Given_a_productcode_When_set_to_blank_Then_fail_validation()
        {
            ProductModel prodModel = new ProductModel {
                ProductCode = string.Empty, Price = 0
            };
            ValidationModel validModel = validationProcessor.ValidateProduct(prodModel);

            Assert.AreEqual(ValidationStatus.ValidationError, validModel.Status);
        }
Exemple #29
0
        public void Given_a_productcode_When_Starts_with_other_than_A_B_C_Then_fail_validation()
        {
            ProductModel prodModel = new ProductModel {
                ProductCode = "P001", Price = 0
            };
            ValidationModel validModel = validationProcessor.ValidateProduct(prodModel);

            Assert.AreEqual(ValidationStatus.ValidationError, validModel.Status);
        }
Exemple #30
0
        public void Given_a_productcode_When_Starts_with_C_Then_fail_validation_if_price_is_less_than_thousand()
        {
            ProductModel prodModel = new ProductModel {
                ProductCode = "C001", Price = 999
            };
            ValidationModel validModel = validationProcessor.ValidateProduct(prodModel);

            Assert.AreEqual(ValidationStatus.ValidationError, validModel.Status);
        }
        private static bool ValidateRange(int value, ValidationModel validationModel, out string errorMessage)
        {
            if (validationModel.MinValue > value || value > validationModel.MaxValue)
            {
                errorMessage = string.Format("Parameter '{0}' out of range [{1};{2}]. Current value: {3}", validationModel.PublicPropertyName, validationModel.MinValue, validationModel.MaxValue, value);
                return false;
            }

            errorMessage = null;
            return true;
        }
        public void ValidationSummary_InvalidModelWithPrefix_ReturnsExpectedDiv(
            bool excludePropertyErrors,
            bool clientValidationEnabled,
            string expected,
            string ignored)
        {
            // Arrange
            var model = new ValidationModel();
            var html = DefaultTemplatesUtilities.GetHtmlHelper(model);
            html.ViewContext.ClientValidationEnabled = clientValidationEnabled;
            html.ViewData.TemplateInfo.HtmlFieldPrefix = "this.is.my.prefix";
            html.ViewData.ModelState.AddModelError("this.is.my.prefix", "This is my validation message");

            // Act
            var result = html.ValidationSummary(
                excludePropertyErrors,
                message: null,
                htmlAttributes: null,
                tag: null);

            // Assert
            Assert.Equal(expected, result.ToString());
        }
        public void ValidationSummary_AllValid_ReturnsExpectedDiv(
            string message,
            object htmlAttributes,
            string tag,
            string expected)
        {
            // Arrange
            var model = new ValidationModel();
            var html = DefaultTemplatesUtilities.GetHtmlHelper(model);

            // Act
            var result = html.ValidationSummary(
                excludePropertyErrors: false,
                message: message,
                htmlAttributes: htmlAttributes,
                tag: tag);

            // Assert
            Assert.Equal(expected, HtmlContentUtilities.HtmlContentToString(result));
        }
        public void ValidationSummary_ClientValidationDisabledAllValid_ReturnsEmpty(
            string message,
            object htmlAttributes,
            string tag,
            string ignored)
        {
            // Arrange
            var model = new ValidationModel();
            var html = DefaultTemplatesUtilities.GetHtmlHelper(model);
            html.ViewContext.ClientValidationEnabled = false;

            // Act
            var result = html.ValidationSummary(
                excludePropertyErrors: false,
                message: message,
                htmlAttributes: htmlAttributes,
                tag: tag);

            // Assert
            Assert.Equal(HtmlString.Empty, result);
        }
        public void ValidationSummary_OneInvalidProperty_ReturnsExpectedDiv(
            bool excludePropertyErrors,
            bool clientValidationEnabled,
            string ignored,
            string expected)
        {
            // Arrange
            var model = new ValidationModel();
            var html = DefaultTemplatesUtilities.GetHtmlHelper(model);
            html.ViewContext.ClientValidationEnabled = clientValidationEnabled;
            html.ViewData.ModelState.AddModelError("Property1", "This is my validation message");

            // Act
            var result = html.ValidationSummary(
                excludePropertyErrors,
                message: null,
                htmlAttributes: null,
                tag: null);

            // Assert
            Assert.Equal(expected, HtmlContentUtilities.HtmlContentToString(result));
        }
        public void ValidationSummary_MultipleErrors_ReturnsExpectedDiv(
            bool excludePropertyErrors,
            string prefix,
            string expected)
        {
            // Arrange
            var model = new ValidationModel();
            var html = DefaultTemplatesUtilities.GetHtmlHelper(model);
            html.ViewData.TemplateInfo.HtmlFieldPrefix = prefix;
            AddMultipleErrors(html.ViewData.ModelState);

            // Act
            var result = html.ValidationSummary(
                excludePropertyErrors,
                message: null,
                htmlAttributes: null,
                tag: null);

            // Assert
            Assert.Equal(expected, HtmlContentUtilities.HtmlContentToString(result));
        }