public int Create(AddMutualFundVm addMutualFundVm) { var mutualFund = new MutualFund() { Title = addMutualFundVm.Title, Symbol = addMutualFundVm.Symbol, }; DbOperationStatus opStatus = MutualRepository.InsertMutualFund(mutualFund); if (opStatus.OperationSuccessStatus) { return(opStatus.AffectedIndices.First()); } return(-1); }
public ActionResult Add(AddMutualFundVm addMutualFundVm) { if (ModelState.IsValid) { if (!MutualFundService.ValidateDuplicateSymbol(addMutualFundVm.Symbol)) { int mutualFundId = MutualFundService.Create(addMutualFundVm); if (mutualFundId > 0) { this.FlashSuccess("Successfully created the mutual fund.", "Details", "MutualFunds"); return(RedirectToAction("Details", "MutualFunds", new { area = "", id = mutualFundId })); } this.FlashError("Could not create the mutual fund. Please try again.", "Add", "MutualFunds"); } else { ModelState.AddModelError("Symbol", "The provided mutual fund already exists."); this.FlashError("The provided mutual fund already exists.", "Add", "MutualFunds"); } } return(View(addMutualFundVm)); }