Ejemplo n.º 1
0
        public CreatePartyPage()
        {
            InitializeComponent();
            CreatePartyViewModel myViewModel = new CreatePartyViewModel();

            //myViewModel.ResultMap = ResultMap;
            BindingContext = myViewModel;
        }
Ejemplo n.º 2
0
        public IActionResult Create(int?id = null)
        {
            var model = new CreatePartyViewModel {
                Accounts  = AccountsSelectListItems(),
                AccountID = id
            };

            return(View(model));
        }
Ejemplo n.º 3
0
        public ActionResult Add(CreatePartyViewModel partyViewModel)
        {
            if (ModelState.IsValid)
            {
                Party party = _mapper.Map <Party>(partyViewModel);

                _partyService.AddParty(party);

                return(RedirectToAction("List", "Party", new { id = partyViewModel.OwnerId }));
            }
            else
            {
                return(View(partyViewModel));
            }
        }
Ejemplo n.º 4
0
        public IActionResult Create(CreatePartyViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Accounts = AccountsSelectListItems();

                return(View(model));
            }

            Db.InsertOrUpdate(new Party(
                                  accountID: model.AccountID.Value,
                                  name: model.Name
                                  ));

            UnitOfWork.CommitChanges();

            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 5
0
        public ActionResult Create()
        {
            var citizen         = SessionHelper.LoggedCitizen;
            var country         = citizen.Region.Country;
            var countryPolicies = country.CountryPolicy;
            var countryMoney    = country.Currency;
            var configuration   = ConfigurationHelper.Configuration;

            if (citizen.PartyMember != null)
            {
                return(YouAreAlreadyMemberOfThePartyRedirection());
            }

            var countryFee = new MoneyViewModel(countryMoney, countryPolicies.PartyFoundingFee);
            var adminFee   = new MoneyViewModel(GameHelper.Gold, configuration.PartyFoundingFee);


            CreatePartyViewModel vm = new CreatePartyViewModel(adminFee, countryFee);

            return(View(vm));
        }
Ejemplo n.º 6
0
        public ActionResult Create(CreatePartyViewModel vm)
        {
            var citizen         = SessionHelper.LoggedCitizen;
            var country         = citizen.Region.Country;
            var countryPolicies = country.CountryPolicy;
            var countryCurrency = country.Currency;
            var configuration   = ConfigurationHelper.Configuration;

            var validator = new PartyCreateValidator(ModelState, entityService);


            var countryFee = new MoneyViewModel(countryCurrency, countryPolicies.PartyFoundingFee);
            var adminFee   = new MoneyViewModel(GameHelper.Gold, configuration.PartyFoundingFee);

            if (validator.IsValid)
            {
                var party = partyService.CreateParty(vm.Name, citizen, country);

                var adminMoney = new Money()
                {
                    Amount   = adminFee.Quantity,
                    Currency = GameHelper.Gold
                };

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

                var adminTransaction = new Transaction()
                {
                    Arg1 = "Admin Fee",
                    Arg2 = string.Format("{0}({1}) created party {2}({3})", citizen.Entity.Name, citizen.Entity.EntityID, party.Entity.Name, party.ID),
                    DestinationEntityID = null,
                    Money           = adminMoney,
                    SourceEntityID  = citizen.Entity.EntityID,
                    TransactionType = TransactionTypeEnum.PartyCreate
                };
                var countryTransaction = new Transaction()
                {
                    Arg1 = "Country Fee",
                    Arg2 = adminTransaction.Arg2,
                    DestinationEntityID = country.ID,
                    Money           = countryMoney,
                    SourceEntityID  = citizen.Entity.EntityID,
                    TransactionType = TransactionTypeEnum.PartyCreate
                };

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

                AddMessage(new PopupMessageViewModel(string.Format("Party {0} was created!", party.Entity.Name)));
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                RedirectBack();
            }



            vm.CountryFee = countryFee;
            vm.AdminFee   = adminFee;

            return(View(vm));
        }
Ejemplo n.º 7
0
 public CreatePartyView()
 {
     createPartyViewModel = new CreatePartyViewModel(this);
     BindingContext       = createPartyViewModel;
     InitializeComponent();
 }