private bool Validate()
        {
            ValidationErrors validationErrors = new ValidationErrors();

            if (_model.CountryName == null || _model.CountryName.Trim().Length == 0)
            {
                validationErrors.Add(string.Format(TextResources.Required_IsMandatory, TextResources.Country));
            }
            if (_model.Address == null || _model.Address.Trim().Length == 0)
            {
                validationErrors.Add(string.Format(TextResources.Required_IsMandatory, TextResources.Address));
            }
            if (_model.CityName == null || _model.CityName.Trim().Length == 0)
            {
                validationErrors.Add(string.Format(TextResources.Required_IsMandatory, TextResources.City));
            }
            if (_model.StateName == null || _model.StateName.Trim().Length == 0)
            {
                validationErrors.Add(string.Format(TextResources.Required_IsMandatory, TextResources.State));
            }
            if (_model.PostalCode == null || _model.PostalCode.Trim().Length == 0)
            {
                validationErrors.Add(string.Format(TextResources.Required_IsMandatory, TextResources.PostalCode));
            }
            if (validationErrors.Count() > 0)
            {
                _model.SetActivityResource(showError: true,
                                           errorMessage: validationErrors.Count() > 2
                        ? TextResources.Required_AllInputs
                        : validationErrors.Show(CommonConstants.SPACE));
            }
            return(validationErrors.Count() == 0);
        }
        private bool Validate()
        {
            ValidationErrors validationErrors = new ValidationErrors();

#if DEBUG
            if (string.IsNullOrEmpty(_model.ImageFront) || _model.ImageFront == _model.ImageDefault)
            {
                _model.ImageFront = "Uploads/no.png";
            }
            if (string.IsNullOrEmpty(_model.ImageSide) || _model.ImageSide == _model.ImageDefault)
            {
                _model.ImageSide = "Uploads/no.png";
            }
#endif
            if (_model.ImageFront == _model.ImageDefault)
            {
                validationErrors.Add(string.Format(TextResources.Required_IsMandatory, TextResources.FrontPhoto));
            }
            if (_model.ImageSide == _model.ImageDefault)
            {
                validationErrors.Add(string.Format(TextResources.Required_IsMandatory, TextResources.SidePhoto));
            }

            if (validationErrors.Count() > 0)
            {
                _model.SetActivityResource(showError: true, errorMessage: validationErrors.Show(CommonConstants.SPACE));
            }
            return(validationErrors.Count() == 0);
        }
Beispiel #3
0
        private bool Validate()
        {
            ValidationErrors validationErrors = new ValidationErrors();

            if (string.IsNullOrEmpty(_model.SelectedApplication))
            {
                validationErrors.Add(string.Format(TextResources.Required_MustBeSelected, TextResources.Region));
            }
            if (string.IsNullOrEmpty(_model.EmailAddress))
            {
                validationErrors.Add(string.Format(TextResources.Required_IsMandatory, TextResources.EmailAddress));
            }
            else if (!Regex.IsMatch(_model.EmailAddress.Trim(), CommonConstants.EMAIL_VALIDATION_REGEX))
            {
                validationErrors.Add(string.Format(TextResources.Validation_IsInvalid, TextResources.EmailAddress));
            }
            if (string.IsNullOrEmpty(_model.UserPassword))
            {
                validationErrors.Add(string.Format(TextResources.Required_IsMandatory, TextResources.Password));
            }
            else if (string.IsNullOrWhiteSpace(_model.UserPassword))
            {
                validationErrors.Add(string.Format(TextResources.Validation_IsInvalid, TextResources.Password));
            }
            else if (_model.UserPassword.Trim().Length < 5)
            {
                validationErrors.Add(string.Format(TextResources.Validation_LengthMustBeMoreThan,
                                                   TextResources.Password, 5));
            }
            else if (_model.UserPassword.Trim().Length > 100)
            {
                validationErrors.Add(string.Format(TextResources.Validation_LengthMustBeLessThan,
                                                   TextResources.Password, 100));
            }
            if (string.IsNullOrEmpty(_model.UserConfirmPassword))
            {
                validationErrors.Add(string.Format(TextResources.Required_IsMandatory,
                                                   TextResources.ConfirmPassword));
            }
            else if (_model.UserPassword != _model.UserConfirmPassword)
            {
                validationErrors.Add(TextResources.MessagePasswordAndConfirmPasswordNotMatch);
            }
            if (!_model.CheckedTermAndConditions)
            {
                validationErrors.Add(TextResources.MessageMustAgree);
            }

            if (validationErrors.Count() > 0)
            {
                _model.SetActivityResource(showError: true, errorMessage: validationErrors.Show(CommonConstants.SPACE));
            }
            return(validationErrors.Count() == 0);
        }
Beispiel #4
0
        public bool ConfirmFeedList(ref ValidationErrors errors, string opt, string releaseBillNums)
        {
            try
            {
                foreach (string releaseBillNum in releaseBillNums.Split(','))
                {
                    var rtn = m_Rep.ConfirmFeedList(opt, releaseBillNum);
                    if (!String.IsNullOrEmpty(rtn))
                    {
                        errors.Add(rtn);
                    }
                }

                if (errors.Count() > 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.InnerException != null ? ex.InnerException.Message : ex.Message);
                return(false);
            }
        }
Beispiel #5
0
        public JsonResult Delete(string id)
        {
            if (!string.IsNullOrWhiteSpace(id))
            {
                ValidationErrors errors = new ValidationErrors();
                OpeCur.ServiceSession.SysModule.DeleteAndClear(ref errors, id);

                if (errors.Count() > 0) {
                    return OpeCur.AjaxMsgNOOK(errors.Error);
                }


                if (OpeCur.ServiceSession.SaveChange() > 0)
                {
                    LogHandler.WriteServiceLog(OpeCur.AccountNow.Id, "Ids:" + id, "成功", "删除", "模块设置");
                    return OpeCur.AjaxMsgOK(Resource.DeleteSucceed);
                    //return Json(JsonHandler.CreateMessage(1, Resource.DeleteSucceed), JsonRequestBehavior.AllowGet);
                }
                else
                {
                    string ErrorCol = errors.Error;
                    LogHandler.WriteServiceLog(OpeCur.AccountNow.Id, "Id:" + id + "," + ErrorCol, "失败", "删除", "模块设置");
                    return OpeCur.AjaxMsgError(Resource.DeleteFail + ":" + ErrorCol);
                    //return Json(JsonHandler.CreateMessage(0, Resource.DeleteFail + ErrorCol), JsonRequestBehavior.AllowGet);
                }
            }
            else
            {
                return OpeCur.AjaxMsgNOOK("Id为空!");
                //return Json(JsonHandler.CreateMessage(0, Resource.DeleteFail), JsonRequestBehavior.AllowGet);
            }


        }
        private bool Validate()
        {
            var validationErrors = new ValidationErrors();

            if (_model.EmailAddress == null || _model.EmailAddress.Trim().Length == 0)
            {
                validationErrors.Add(string.Format(TextResources.Required_IsMandatory, TextResources.EmailAddress));
            }
            else if (!Regex.IsMatch(_model.EmailAddress.Trim(), CommonConstants.EMAIL_VALIDATION_REGEX))
            {
                validationErrors.Add(string.Format(TextResources.Validation_IsInvalid, TextResources.EmailAddress));
            }
            if (validationErrors.Count() > 0)
            {
                _model.SetActivityResource(showError: true, errorMessage: validationErrors.Show(CommonConstants.SPACE));
            }
            return(validationErrors.Count() == 0);
        }
Beispiel #7
0
        private bool Validate()
        {
            ValidationErrors validationErrors = new ValidationErrors();

            if (_model.FirstName == null || _model.FirstName.Trim().Length == 0)
            {
                validationErrors.Add(string.Format(TextResources.Required_IsMandatory, TextResources.FirstName));
            }
            if (_model.LastName == null || _model.LastName.Trim().Length == 0)
            {
                validationErrors.Add(string.Format(TextResources.Required_IsMandatory, TextResources.LastName));
            }
            if (validationErrors.Count() > 0)
            {
                _model.SetActivityResource(showError: true, errorMessage: validationErrors.Show(CommonConstants.SPACE));
            }
            return(validationErrors.Count() == 0);
        }
Beispiel #8
0
        private bool Validate()
        {
            ValidationErrors validationErrors = new ValidationErrors();

            if (string.IsNullOrEmpty(_model.CurrentPassword))
            {
                validationErrors.Add(string.Format(TextResources.Required_IsMandatory,
                                                   TextResources.CurrentPassword));
            }
            if (string.IsNullOrEmpty(_model.NewPassword))
            {
                validationErrors.Add(string.Format(TextResources.Required_IsMandatory, TextResources.NewPassword));
            }
            else if (string.IsNullOrWhiteSpace(_model.NewPassword))
            {
                validationErrors.Add(string.Format(TextResources.Validation_IsInvalid, TextResources.NewPassword));
            }
            else if (_model.NewPassword.Trim().Length < 5)
            {
                validationErrors.Add(string.Format(TextResources.Validation_LengthMustBeMoreThan,
                                                   TextResources.Password, 5));
            }
            else if (_model.NewPassword.Trim().Length > 100)
            {
                validationErrors.Add(string.Format(TextResources.Validation_LengthMustBeLessThan,
                                                   TextResources.Password, 100));
            }
            if (string.IsNullOrEmpty(_model.ConfirmNewPassword))
            {
                validationErrors.Add(string.Format(TextResources.Required_IsMandatory,
                                                   TextResources.ConfirmNewPassword));
            }
            else if (_model.NewPassword != _model.ConfirmNewPassword)
            {
                validationErrors.Add(TextResources.MessagePasswordAndConfirmPasswordNotMatch);
            }
            if (validationErrors.Count() > 0)
            {
                _model.SetActivityResource(showError: true, errorMessage: validationErrors.Show("\n"));
            }
            return(validationErrors.Count() == 0);
        }
        string FormatErrors(string repoName, ValidationErrors validationErrors)
        {
            var maxNumIssuesToShow = 10;

            var sb = new StringBuilder();

            sb.AppendLine("The following issues for " + repoName + " needs attention");

            foreach (var error in validationErrors.Take(maxNumIssuesToShow)) //nsb is to big for now
            {
                sb.AppendLine($"{error.Issue.HtmlUrl} - {error.Reason}");
            }

            if (validationErrors.Count() > maxNumIssuesToShow)
            {
                sb.AppendLine($"There are {validationErrors.Count() - maxNumIssuesToShow} more issues as well. I'll soon be able to show you them using: `pbot check repo {repoName} detailed`");
            }

            sb.AppendLine("Unsure how to go about doing this? Please read more here: https://github.com/Particular/Housekeeping/wiki/Issue-management");
            return sb.ToString();
        }
Beispiel #10
0
        private bool Validate()
        {
            var validationErrors = new ValidationErrors();

            if (string.IsNullOrEmpty(EntryUsername?.Text))
            {
                validationErrors.Add(string.Format(TextResources.Required_IsMandatory, TextResources.Username));
            }
            else if (!Regex.IsMatch((EntryUsername?.Text ?? "").Trim(), CommonConstants.EMAIL_VALIDATION_REGEX))
            {
                validationErrors.Add(string.Format(TextResources.Validation_IsInvalid, TextResources.Username));
            }
            if (string.IsNullOrEmpty(EntryPassword?.Text))
            {
                validationErrors.Add(string.Format(TextResources.Required_IsMandatory, TextResources.Password));
            }
            else if (string.IsNullOrWhiteSpace(EntryPassword.Text))
            {
                validationErrors.Add(string.Format(TextResources.Validation_IsInvalid, TextResources.Password));
            }
            else if (EntryPassword.Text.Trim().Length < 5)
            {
                validationErrors.Add(string.Format(TextResources.Validation_LengthMustBeMoreThan,
                                                   TextResources.Password, 5));
            }
            else if (EntryPassword.Text.Trim().Length > 50)
            {
                validationErrors.Add(string.Format(TextResources.Validation_LengthMustBeLessThan,
                                                   TextResources.Password, 50));
            }
            if (validationErrors.Count() > 0)
            {
                _model.SetActivityResource(showError: true,
                                           errorMessage: validationErrors.Count() > 2
                        ? TextResources.Required_AllInputs
                        : validationErrors.Show(CommonConstants.SPACE));
            }
            return(validationErrors.Count() == 0);
        }
        private bool Validate()
        {
            var validationErrors = new ValidationErrors();

            if (string.IsNullOrEmpty(_model.SecretCode))
            {
                validationErrors.Add(string.Format(TextResources.Required_IsMandatory,
                                                   TextResources.AuthorizationCode));
            }
            else if (string.IsNullOrEmpty(_model.Password))
            {
                validationErrors.Add(string.Format(TextResources.Required_IsMandatory, TextResources.NewPassword));
            }
            else if (_model.Password.Trim().Length < 5)
            {
                validationErrors.Add(string.Format(TextResources.Validation_LengthMustBeMoreThan,
                                                   TextResources.Password, 5));
            }
            else if (_model.Password.Trim().Length > 100)
            {
                validationErrors.Add(string.Format(TextResources.Validation_LengthMustBeLessThan,
                                                   TextResources.Password, 100));
            }
            else if (string.IsNullOrEmpty(_model.ConfirmPassword))
            {
                validationErrors.Add(string.Format(TextResources.Required_IsMandatory,
                                                   TextResources.ConfirmPassword));
            }
            else if (_model.Password.Trim() != _model.ConfirmPassword.Trim())
            {
                validationErrors.Add(TextResources.MessagePasswordAndConfirmPasswordNotMatch);
            }

            if (validationErrors.Count() > 0)
            {
                _model.SetActivityResource(showError: true, errorMessage: validationErrors.Show(CommonConstants.SPACE));
            }
            return(validationErrors.Count() == 0);
        }
Beispiel #12
0
        private void UpdateValidationErrors(string propertyName, IEnumerable <string> errors)
        {
            errors = errors.ToList();
            var fullName = string.Format("{0}.{1}", GetType().FullName, propertyName);
            var before   = ValidationErrors.Count(x => x.Value.Any());

            ValidationErrors[fullName] = errors;
            var after = ValidationErrors.Count(x => x.Value.Any());

            if (before != after)
            {
                OnValidationStateChanged();
            }
        }
 public HtmlString GetValidationErrors(string title = "Validation Error")
 {
     if (ValidationErrors.Count() > 0)
     {
         var temp = "";
         temp += "<ul class=\"alert alert-danger list-unstyled\">";
         temp += String.Format("<li><h3 class=\"text-danger\"><i class=\"fa fa-exclamation-triangle\"></i>{0}</h3></li>", title);
         foreach (ValidationError el in ValidationErrors)
         {
             temp += $"<li><strong>{el.ErrorField} : </strong> {el.ErrorMessage}</li>";
         }
         temp += "</ul>";
         return(new HtmlString(temp));
     }
     else
     {
         return(new HtmlString(string.Empty));
     }
 }
Beispiel #14
0
        public JsonResult UpdateRight(List <SysRightUpdateModel> data)
        {
            //data = "[{ 'id': '201704200905260490999d531a42553','checked':true}]";
            //List<TreeNode> datas = JsonConvert.DeserializeObject<List<TreeNode>>(data);
            ValidationErrors errors = new ValidationErrors();

            OpeCur.ServiceSession.SysRight.UpdateRight(ref errors, data);
            if (errors.Count() > 0)
            {
                return(OpeCur.AjaxMsgNOOK(errors.Error));
            }

            //if (OpeCur.ServiceSession.SaveChange() > 0)
            //{
            return(OpeCur.AjaxMsgOK("操作成功"));
            //}
            //else
            //{
            //    return OpeCur.AjaxMsgNOOK("操作失败");
            //}
        }
Beispiel #15
0
 public bool CheckImportData(string fileName, List <MIS_PersonModel> personList, ref ValidationErrors errors)
 {
     try
     {
         var targetFile = new FileInfo(fileName);
         if (!targetFile.Exists)
         {
             errors.add("文件不存在");
             return(false);
         }
         var excelFile = new ExcelQueryFactory(fileName);
         //对应表头
         excelFile.AddMapping <MIS_PersonModel>(x => x.Name, "Name");
         excelFile.AddMapping <MIS_PersonModel>(x => x.Sex, "Sex");
         excelFile.AddMapping <MIS_PersonModel>(x => x.Age, "Age");
         excelFile.AddMapping <MIS_PersonModel>(x => x.IDCard, "IDCard");
         excelFile.AddMapping <MIS_PersonModel>(x => x.Phone, "Phone");
         excelFile.AddMapping <MIS_PersonModel>(x => x.Email, "Email");
         excelFile.AddMapping <MIS_PersonModel>(x => x.Address, "Address");
         excelFile.AddMapping <MIS_PersonModel>(x => x.Region, "Region");
         excelFile.AddMapping <MIS_PersonModel>(x => x.Category, "Category");
         //sheetName
         var excelContent = excelFile.Worksheet <MIS_PersonModel>(0);
         int rowIndex     = 1;
         //检查数据正确性
         foreach (var row in excelContent)
         {
             var errorMessage = new StringBuilder();
             var person       = new MIS_PersonModel();
             person.Id       = row.Id;
             person.Name     = row.Name;
             person.Sex      = row.Sex;
             person.Age      = row.Age;
             person.IDCard   = row.IDCard;
             person.Phone    = row.Phone;
             person.Email    = row.Email;
             person.Address  = row.Address;
             person.Region   = row.Region;
             person.Category = row.Category;
             if (string.IsNullOrEmpty(person.Name))
             {
                 errorMessage.Append("Name - 不能为空. ");
             }
             if (string.IsNullOrWhiteSpace(row.IDCard))
             {
                 errorMessage.Append("IDCard - 不能为空. ");
             }
             if (errorMessage.Length > 0)
             {
                 errors.add(string.Format("第{0}行发现错误:{1}{2}", rowIndex, errorMessage, "<br />"));
             }
             else
             {
                 personList.Add(person);
             }
             rowIndex++;
         }
         if (errors.Count() > 0)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
         errors.add("数据表列名不合法");
         ExceptionHandler.WriteException(ex);
         return(false);
     }
 }
        public bool CheckImportData(string fileName, ref List <MIS_ProfessorOuterModel> modelList, ref ValidationErrors errors)
        {
            try
            {
                var excel = new ExcelQueryFactory(fileName);
                //映射excel列名
                excel.AddMapping <MIS_ProfessorOuterModel>(r => r.uid, "证书编号");
                excel.AddMapping <MIS_ProfessorOuterModel>(r => r.name, "姓名");
                excel.AddMapping <MIS_ProfessorOuterModel>(r => r.stuNumPG, "意向人数");
                excel.AddMapping <MIS_ProfessorOuterModel>(r => r.sex, "性别");
                excel.AddMapping <MIS_ProfessorOuterModel>(r => r.position, "职称/职务");
                excel.AddMapping <MIS_ProfessorOuterModel>(r => r.department, "单位");
                excel.AddMapping <MIS_ProfessorOuterModel>(r => r.mobile, "手机");
                excel.AddMapping <MIS_ProfessorOuterModel>(r => r.email, "邮箱");
                excel.AddMapping <MIS_ProfessorOuterModel>(r => r.area, "熟悉的业务内容");
                excel.AddMapping <MIS_ProfessorOuterModel>(r => r.profession, "所属行业");
                excel.AddMapping <MIS_ProfessorOuterModel>(r => r.office, "办公地址");

                var excelContent = excel.WorksheetRange <MIS_ProfessorOuterModel>("A2", "K100", "2016届");

                int rowIndex = 1;
                foreach (var row in excelContent)
                {
                    var errorMessage = new StringBuilder();
                    var professor    = new MIS_ProfessorOuterModel();
                    professor.Id         = row.Id;
                    professor.uid        = row.uid;
                    professor.name       = row.name;
                    professor.sex        = row.sex;
                    professor.position   = row.position;
                    professor.department = row.department;
                    professor.mobile     = row.mobile;
                    professor.email      = row.email;
                    professor.area       = row.area;
                    professor.profession = row.profession;
                    professor.office     = row.office;
                    if (professor.uid == null)
                    {
                        errorMessage.Append("证书编号 - 不能为空");
                    }
                    if (errorMessage.Length > 0)
                    {
                        errors.add(string.Format("第{0}行发现错误 :{1}{2}", rowIndex, errorMessage.ToString(), "<br />"));
                    }
                    else
                    {
                        modelList.Add(professor);
                    }
                    rowIndex++;
                }
                if (errors.Count() > 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                errors.add(ex.Message);
                ExceptionHandler.WriteException(ex);
                return(false);
            }
        }
        private bool Validate()
        {
            _model.NextButtonText = TextResources.Next;
            ValidationErrors validationErrors = new ValidationErrors();

            if (_model.AgeValue == 0)
            {
                validationErrors.Add(string.Format(TextResources.Required_IsMandatory, TextResources.YourAge));
            }
            else if (_model.AgeValue < App.Configuration.AppConfig.MINIMUM_AGE)
            {
                validationErrors.Add(string.Format(TextResources.Validation_MustBeMoreThan, TextResources.YourAge,
                                                   App.Configuration.AppConfig.MINIMUM_AGE));
            }

            if (_model.CurrentWeightValue == 0)
            {
                validationErrors.Add(string.Format(TextResources.Required_IsMandatory,
                                                   TextResources.YourCurrentWeight));
            }
            else if (_model.CurrentWeightValue <
                     _converter.DisplayWeightVolume(App.Configuration.AppConfig.MINIMUM_CURRENT_WEIGHT_KG,
                                                    App.Configuration.AppConfig.MINIMUM_CURRENT_WEIGHT_LB))
            {
                validationErrors.Add(string.Format(TextResources.Validation_MustBeMoreThan,
                                                   TextResources.YourCurrentWeight,
                                                   _converter.DisplayWeightVolume(App.Configuration.AppConfig.MINIMUM_CURRENT_WEIGHT_KG,
                                                                                  App.Configuration.AppConfig.MINIMUM_CURRENT_WEIGHT_LB)));
            }

            if (_model.WeightLossGoalValue == 0)
            {
                validationErrors.Add(
                    string.Format(TextResources.Required_IsMandatory, TextResources.WeightLossGoal));
            }
            else if (_model.WeightLossGoalValue <
                     _converter.DisplayWeightVolume(App.Configuration.AppConfig.MINIMUM_WEIGHT_LOSE_KG,
                                                    App.Configuration.AppConfig.MINIMUM_WEIGHT_LOSE_LB))
            {
                validationErrors.Add(string.Format(TextResources.Validation_MustBeMoreThan,
                                                   TextResources.WeightLossGoal,
                                                   _converter.DisplayWeightVolume(App.Configuration.AppConfig.MINIMUM_WEIGHT_LOSE_KG,
                                                                                  App.Configuration.AppConfig.MINIMUM_WEIGHT_LOSE_LB)));
            }
            else if (_model.WeightLossGoalValue > _model.CurrentWeightValue)
            {
                validationErrors.Add(string.Format(TextResources.Validation_MustBeLessThan, TextResources.WeightLossGoal, TextResources.YourCurrentWeight));
            }

            _model.ReviseHeaderText          = _model.ReviseRequestText = string.Empty;
            labelReviseRequest.FormattedText = new FormattedString();
            if (!IsRevised && (_model.WeightLossGoalValue > ((_model.CurrentWeightValue / 100) * _model.WeightLoseWarningPercent)))
            {
                _model.ReviseRequestText = string.Format(TextResources.ReviseWeightText, (int)((_model.WeightLossGoalValue * 100) / _model.CurrentWeightValue));
                _model.ReviseHeaderText  = TextResources.Warning;
                validationErrors.Add(_model.ReviseRequestText);
                _model.NextButtonText = TextResources.Yes + ", " + TextResources.Continue;

                try {
                    labelReviseRequest.FormattedText = new FormattedString()
                    {
                        Spans =
                        {
                            new Span()
                            {
                                Text            = _model.ReviseHeaderText,
                                ForegroundColor = Palette._Error,
                                FontAttributes  = FontAttributes.Bold,
                            },
                            new Span()
                            {
                                Text            = ": ",
                                ForegroundColor = Palette._Error,
                                FontAttributes  = FontAttributes.Bold,
                            },
                            new Span()
                            {
                                Text            = _model.ReviseRequestText,
                                ForegroundColor = Palette._White,
                                FontAttributes  = FontAttributes.None,
                            },
                        }
                    };
                }
                catch (Exception ex)
                {
                    new ExceptionHandler(TAG, ex);
                }
            }
            IsRevised = true;

            if (validationErrors.Count() > 0)
            {
                _model.SetActivityResource(showError: true,
                                           errorMessage: validationErrors.Count() > 2
                        ? TextResources.Required_AllInputs
                        : validationErrors.Show(CommonConstants.SPACE));
            }
            return(validationErrors.Count() == 0);
        }
Beispiel #18
0
        private bool Validate()
        {
            if (App.CurrentUser.UserInfo.UserEmail.ToLower().Contains("apple") &&
                App.CurrentUser.UserInfo.UserEmail.ToLower().Contains("@organogold.com"))
            {
                return(true);
            }

            var validationErrors = new ValidationErrors();

            // Current Weight
            if (CurrentWeightValue == 0)
            {
                validationErrors.Add(
                    string.Format(TextResources.Required_IsMandatory, TextResources.WeightLossGoal));
            }
            else if (CurrentWeightValue <
                     _converter.DisplayWeightVolume(
                         App.Configuration.AppConfig.MINIMUM_WEIGHT_LOSE_KG,
                         App.Configuration.AppConfig.MINIMUM_CURRENT_WEIGHT_LB))
            {
                validationErrors.Add(string.Format(TextResources.Validation_MustBeMoreThan,
                                                   TextResources.WeightLossGoal,
                                                   _converter.DisplayWeightVolume(
                                                       App.Configuration.AppConfig.MINIMUM_WEIGHT_LOSE_KG,
                                                       App.Configuration.AppConfig.MINIMUM_CURRENT_WEIGHT_LB)));
            }

            if (GoalAchieved)
            {
                #if DEBUG
                if (string.IsNullOrEmpty(ImageFront) || ImageFront == ImageDefault)
                {
                    ImageFront = "Uploads/no.png";
                }
                if (string.IsNullOrEmpty(ImageSide) || ImageSide == ImageDefault)
                {
                    ImageSide = "Uploads/no.png";
                }
                #endif

                // Front Photo
                if (string.IsNullOrEmpty(ImageFront) || ImageFront == ImageDefault)
                {
                    validationErrors.Add(string.Format(TextResources.Required_MustBeSelected,
                                                       TextResources.FrontPhoto));
                }

                // Side Photo
                if (string.IsNullOrEmpty(ImageSide) || ImageSide == ImageDefault)
                {
                    validationErrors.Add(string.Format(TextResources.Required_MustBeSelected,
                                                       TextResources.SidePhoto));
                }

                //Gender
                if (IsGenderRequired && !IsGenderSelected)
                {
                    validationErrors.Add(string.Format(TextResources.Required_MustBeSelected,
                                                       TextResources.Gender));
                }

                // T-Shirt Size
                if (string.IsNullOrEmpty(TShirtSize))
                {
                    validationErrors.Add(string.Format(TextResources.Required_MustBeSelected,
                                                       TextResources.TShirtSize));
                }

                // Why you want to join
                if (string.IsNullOrEmpty(AboutYourJourney))
                {
                    validationErrors.Add(string.Format(TextResources.Required_IsMandatory,
                                                       TextResources.AboutYourJourney));
                }
            }

            if (validationErrors.Count() > 0)
            {
                SetActivityResource(showError: true,
                                    errorMessage: validationErrors.Count() > 2
                        ? TextResources.PleaseReviewAllInputsAreMandatory
                        : validationErrors.Show("\n"), modalWindow: true);
            }

            return(validationErrors.Count() == 0);
        }
Beispiel #19
0
        private async Task <bool> Validate()
        {
            var validationErrors = new ValidationErrors();
            await Task.Run(() =>
            {
                // Current Weight
                if (CurrentWeightValue == 0)
                {
                    validationErrors.Add(
                        string.Format(TextResources.Required_IsMandatory, TextResources.WeightLossGoal));
                }
                else if (CurrentWeightValue < App.Configuration.AppConfig.MINIMUM_WEIGHT_LOSE)
                {
                    validationErrors.Add(string.Format(TextResources.Validation_MustBeMoreThan,
                                                       TextResources.WeightLossGoal, App.Configuration.AppConfig.MINIMUM_WEIGHT_LOSE));
                }

                if (GoalAchieved)
                {
                    // Front Photo
                    if (ImageFront == null || ImageFront.Trim().Length == 0 ||
                        ImageFront == ImageDefault)
                    {
                        validationErrors.Add(string.Format(TextResources.Required_MustBeSelected,
                                                           TextResources.FrontPhoto));
                    }
                    // Side Photo
                    if (ImageSide == null || ImageSide.Trim().Length == 0 ||
                        ImageSide == ImageDefault)
                    {
                        validationErrors.Add(string.Format(TextResources.Required_MustBeSelected,
                                                           TextResources.SidePhoto));
                    }
                    //Gender
                    if (IsGenderRequired && !IsGenderSelected)
                    {
                        validationErrors.Add(string.Format(TextResources.Required_MustBeSelected,
                                                           TextResources.Gender));
                    }
                    // T-Shirt Size
                    if (TShirtSize == null || TShirtSize.Trim().Length == 0)
                    {
                        validationErrors.Add(string.Format(TextResources.Required_MustBeSelected,
                                                           TextResources.TShirtSize));
                    }
                    // Why you want to join
                    if (AboutYourJourney == null || AboutYourJourney.Trim().Length == 0)
                    {
                        validationErrors.Add(string.Format(TextResources.Required_IsMandatory,
                                                           TextResources.AboutYourJourney));
                    }
                }
            });

            if (validationErrors.Count() > 0)
            {
                SetActivityResource(showError: true,
                                    errorMessage: validationErrors.Count() > 2
                        ? TextResources.PleaseReviewAllInputsAreMandatory
                        : validationErrors.Show("\n"));
            }
            return(validationErrors.Count() == 0);
        }