Exemple #1
0
        public bool Validate(CreateOrganisationViewModel model, Entity entity)
        {
            var wallet       = entity.Wallet;
            var countryMoney = wallet.GetMoney(model.CountryFee.CurrencyID, currencyRepository.GetAll());
            var adminMoney   = wallet.GetMoney(model.AdminFee.CurrencyID, currencyRepository.GetAll());

            if (countryMoney.Amount < model.CountryFee.Quantity)
            {
                AddError("Not enough money", () => model.CountryFee);
            }
            if (adminMoney.Amount < model.AdminFee.Quantity)
            {
                AddError("Not enough gold", () => model.AdminFee);
            }

            var existingCompany = organisationRepository.FirstOrDefault(o => o.Entity.Name == model.OrganisationName);

            if (existingCompany != null)
            {
                AddError("You cannot create organisation with this name!", () => model.OrganisationName);
            }

            return(IsValid);
        }