Пример #1
0
        // GET CREATE INCOME SOURCE
        public ViewResult Create(int ClientID)
        {
            var frequencies = clientsRepository.Frequencies.ToList();

            // create view model
            var viewModel = new IncomeSourceFormViewModel
            {
                Frequencies = new SelectList(frequencies, "FrequencyID", "FrequencyName"),
                clientId = ClientID
            };

            return View("Edit", viewModel);
        }
Пример #2
0
        public ActionResult Edit(IncomeSourceFormViewModel incomeSourceForm)
        {
            var incomeSource = Mapper.Map<IncomeSourceFormViewModel, IncomeSource>(incomeSourceForm);

            if (ModelState.IsValid)
            {
                clientsRepository.SaveIncomeSource(incomeSource);
                TempData["message"] = "Income Source: " + incomeSource.IncomeName + " has been saved.";
                return RedirectToAction("List", "LegalFinance", new { incomeSource.ClientId });
            }
            else // validation error, so redisplay the same view
            {
                incomeSourceForm.Frequencies = new SelectList(clientsRepository.Frequencies.ToList(), "FrequenciesID", "FrequencyName", incomeSourceForm.FrequencyID);
                return View("Edit", incomeSourceForm);
            }
        }