bool ValidData() { bool valid = true; if (Member == null) { RulesViolations.Add(new RuleViolation(Properties.Resources.LoansView_MemberMissing)); return(false); } if (LoanType == null) { RulesViolations.Add(new RuleViolation(Properties.Resources.LoansView_LoanTypeMissing)); return(false); } if (LoanYear == null) { RulesViolations.Add(new RuleViolation(Properties.Resources.LoansView_LoanYearMissing)); return(false); } if (PaymentSequence == null) { RulesViolations.Add(new RuleViolation(Properties.Resources.LoansView_PaySeqMissing)); return(false); } if (Balance < 0) { RulesViolations.Add(new RuleViolation(Properties.Resources.LoansView_InsufBalance)); return(false); } if (Amount == 0) { RulesViolations.Add(new RuleViolation(Properties.Resources.LoansView_ZeroloanAmount)); return(false); } if (_modelState == ModelState.New) { var currYearLoans = _repository.Query( lo => lo.PeriodSetting.Id == LoanYear.Id && lo.PaymentSequence.Id == PaymentSequence.Id ); bool exist = currYearLoans.Any( lo => lo.FamilyMember.Code == Member.Code && lo.LoanType.Code == LoanType.Code ); if (exist) { RulesViolations.Add(new RuleViolation(Properties.Resources.LoansView_ExistMemberLoan)); return(false); } } if (string.IsNullOrEmpty(Description)) { RulesViolations.Add(new RuleViolation(Properties.Resources.LoansView_DescriptionMissing)); return(false); } return(valid); }
private bool ValidData() { if (string.IsNullOrEmpty(StartDate) || !Helper.ValidDate(StartDate)) { RulesViolations.Add(new RuleViolation(Properties.Resources.PeriodView_InvalidStartDate)); return(false); } if (string.IsNullOrEmpty(EndDate) || !Helper.ValidDate(EndDate)) { RulesViolations.Add(new RuleViolation(Properties.Resources.PeriodView_InvalidEndDate)); return(false); } int i = String.CompareOrdinal(StartDate, EndDate); if (i >= 0) { RulesViolations.Add(new RuleViolation(Properties.Resources.PeriodView_InconsistentStartEndDate)); return(false); } string startYearPart = StartDate.Substring(0, 4); string endYearPart = EndDate.Substring(0, 4); if (startYearPart != endYearPart) { RulesViolations.Add(new RuleViolation(Properties.Resources.PeriodView_YearPartNotMatch)); return(false); } if (_modelState == ModelState.New && _repository.GetAll().Any(x => x.StartDate == StartDate)) { RulesViolations.Add(new RuleViolation(Properties.Resources.PeriodView_AlreadyRegistredYear)); return(false); } if (SelectedStatus == null) { RulesViolations.Add(new RuleViolation(Properties.Resources.PeriodView_PeriodStutsMissing)); return(false); } if (CurrentPeriod != null && _currnetModel.Id != CurrentPeriod.Id && SelectedStatus.Id == 2) { RulesViolations.Add(new RuleViolation(Properties.Resources.PeriodView_InvalidPeriodStatus)); return(false); } if (YearSequences.Count == 0) { RulesViolations.Add(new RuleViolation(Properties.Resources.PeriodView_YearSeqMissing)); return(false); } return(true); }
bool ValidData() { bool valid = true; if (Code < 10) { RulesViolations.Add(new RuleViolation(Properties.Resources.LoanTypesView_InvalidCode)); return(false); } if (string.IsNullOrEmpty(Description)) { RulesViolations.Add(new RuleViolation(Properties.Resources.LoanTypesView_MissingDescription)); return(false); } return(valid); }