Example #1
0
        public ActionResult Create(CreateOrganisationViewModel vm)
        {
            PrepareViewModel(vm);
            var validator = new OrganisationCreationValidator(ModelState, currencyRepository, entityRepository, organisationRepository);

            if (validator.Validate(vm, SessionHelper.CurrentEntity))
            {
                var param = new CreateOrganisationParameters()
                {
                    Name      = vm.OrganisationName,
                    OwnerID   = SessionHelper.CurrentEntity.EntityID,
                    CountryID = vm.CountryID
                };

                var org = organisationService.CreateOrganisation(param);

                Transaction adminTransaction, countryTransaction;
                prepareTransactions(vm, SessionHelper.CurrentEntity, org, org.Country, out adminTransaction, out countryTransaction);

                transactionService.MakeTransaction(adminTransaction);
                transactionService.MakeTransaction(countryTransaction);

                return(RedirectToHome());
            }

            return(View(vm));
        }
Example #2
0
        public ActionResult Create()
        {
            CreateOrganisationViewModel vm = new CreateOrganisationViewModel();

            PrepareViewModel(vm);

            return(View(vm));
        }
Example #3
0
        private void PrepareViewModel(CreateOrganisationViewModel vm)
        {
            var citizen = SessionHelper.CurrentEntity.Citizen;
            var country = citizen.Region.Country;

            vm.CountryID   = country.ID;
            vm.CountryName = country.Entity.Name;

            vm.CountryFee = new MoneyViewModel(country.Currency, country.CountryPolicy.OrganisationCreateCost);
            vm.AdminFee   = new MoneyViewModel(currencyRepository.Gold, configurationRepository.First().OrganisationCreationFee);
        }
Example #4
0
        public async Task <ActionResult> CreateOrganisation(CreateOrganisationViewModel model)
        {
            string userId = User.Identity.GetUserId();
            var    user   = await _userManager.FindByIdAsync(userId);

            Business org = new Business
            {
                Name  = model.Name,
                Users = new List <User> {
                    user
                }
            };

            _businessService.Create(org);
            return(RedirectToAction("Index"));
        }
        public IActionResult CreateOrg(CreateOrganisationViewModel model)
        {
            OrganisationDTO organisationDTO = new OrganisationDTO()
            {
                Name            = model.Name,
                Description     = model.Description,
                CountryOfOrigin = model.CountryOfOrigin
            };
            var result = organisationManager.CreateOrganisation(organisationDTO);

            switch (result)
            {
            case OrganisationErrorCodes.NameAlreadyExists:
                ModelState.AddModelError("Name", "Name Already Exists!");
                return(View("CreateOrganisation"));

            case OrganisationErrorCodes.NoError:
                return(RedirectToAction("Index"));

            case OrganisationErrorCodes.UnknownException:
                return(RedirectToAction("Error", "Home", new { errorMessage = "An Unknown error occured while creating an organisation", errorDate = DateTime.Now }));
            }
            return(RedirectToAction("Index"));
        }
Example #6
0
        private void prepareTransactions(CreateOrganisationViewModel vm, Entities.Entity entity, Entities.Organisation organisation, Entities.Country country, out Transaction adminTransaction, out Transaction countryTransaction)
        {
            var adminCurrency   = currencyRepository.GetById(vm.AdminFee.CurrencyID);
            var countryCurrency = currencyRepository.GetById(vm.CountryFee.CurrencyID);

            var adminMoney = new Money()
            {
                Amount   = vm.AdminFee.Quantity,
                Currency = adminCurrency
            };

            var countryMoney = new Money()
            {
                Amount   = vm.CountryFee.Quantity,
                Currency = countryCurrency
            };

            adminTransaction = new Transaction()
            {
                Arg1 = "Admin Fee",
                Arg2 = string.Format("{0}({1}) created organisation {2}({3})", entity.Name, entity.EntityID, organisation.Entity.Name, organisation.ID),
                DestinationEntityID = null,
                Money           = adminMoney,
                SourceEntityID  = entity.EntityID,
                TransactionType = TransactionTypeEnum.CompanyCreate
            };
            countryTransaction = new Transaction()
            {
                Arg1 = "Country Fee",
                Arg2 = adminTransaction.Arg2,
                DestinationEntityID = country.ID,
                Money           = countryMoney,
                SourceEntityID  = entity.EntityID,
                TransactionType = TransactionTypeEnum.CompanyCreate
            };
        }
Example #7
0
 private bool isValid(CreateOrganisationViewModel vm)
 {
     throw new NotImplementedException();
 }