Exemplo n.º 1
0
        public void SeedRandom()
        {
            var members = new List <FamilyMember>()
            {
                new FamilyMember("Bob", "Smith"),
                new FamilyMember("Helen", "Smith"),
            };

            _familyMembersRepository.Add(members);

            var categories = new List <Category>()
            {
                new Category("Cat 1"),
                new Category("Cat 2"),
                new Category("Cat 3"),
            };

            _categoriesRepository.Add(categories);

            var currencies = new List <Currency>()
            {
                new Currency("EUR"),
                new Currency("USD")
            };

            _currenciesRepository.Add(currencies);
        }
        public ActionResult Create(Currency currency)
        {
            if (ModelState.IsValid)
            {
                _repo.Add(currency);
                return(RedirectToAction("Index"));
            }

            return(View(currency));
        }
Exemplo n.º 3
0
        public ActionResult Add(CurrencyView currencyView)
        {
            if (ModelState.IsValid)
            {
                ICurrenciesRepository currenciesRepository = new CurrenciesRepository(db);
                Currency currency = new Currency();

                currencyView.ConvertTo(currencyView, currency);

                currenciesRepository.Add(currency);
                currenciesRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("INSERT", currency.CurrencyPK);

                return(RedirectToAction("Index", "Currency"));
            }
            else
            {
                return(View(currencyView));
            }
        }