public ActionResult Edit([Bind(Include = "Id,OwnerId,AccountHolder,IsActive,FinancialInstitution,AccountNumber,AccountTypeId,AssetTypeId,CurrencyTypeId")] PortfolioAccountViewModel model) { if (ModelState.IsValid) { var portfolioAccount = Mapper.Map <PortfolioAccount>(model); _unitOfWork.PortfolioAccounts.Update(portfolioAccount); _unitOfWork.Complete(); return(RedirectToAction("Index")); } SetupSelectList(model); return(View(model)); }
// GET: PortfolioAccounts/Create public ActionResult Create() { ViewBag.AccountTypeId = new SelectList(_unitOfWork.AccountTypes.GetAll(), "Id", "Name"); ViewBag.AssetTypeId = new SelectList(_unitOfWork.AssetTypes.GetAll(), "Id", "TypeName"); ViewBag.CurrencyTypeId = new SelectList(_unitOfWork.CurrencyTypes.GetAll(), "Id", "CurrencyName"); var model = new PortfolioAccountViewModel { IsActive = true, AccountHolder = User.Identity.GetName(), }; return(View(model)); }
private void SetupSelectList(PortfolioAccountViewModel model) { ViewBag.AccountTypeId = new SelectList(_unitOfWork.AccountTypes.GetAll(), "Id", "Name", model.AccountTypeId); ViewBag.AssetTypeId = new SelectList(_unitOfWork.AssetTypes.GetAll(), "Id", "TypeName", model.AssetTypeId); ViewBag.CurrencyTypeId = new SelectList(_unitOfWork.CurrencyTypes.GetAll(), "Id", "CurrencyName", model.CurrencyTypeId); }