public ViewResult Create([Bind(Exclude = "Id")] AccountInfoEditModel model) { if (!ModelState.IsValid) { return(View("Create", model)); } try { var result = _accountInfoService.SaveOneAccountInfo(model.AccountInfo); if (result == StorageResult.Success) { model.FillDropDownLists(); ViewData["Message"] = "Kontoinformasjonen er opprettet"; return(View("Create", model)); } if (result == StorageResult.AllreadyExsists) { model.FillDropDownLists(); ViewData["Message"] = "Kontoinformasjon med samme nummer og år finnes fra før."; return(View("Create", model)); } model.FillDropDownLists(); ViewData["Message"] = "Ukjent feil under lagring."; return(View("Create", model)); } catch { model.FillDropDownLists(); ViewData["Message"] = "Feil i underliggende tjenester under lagring."; return(View("Create", model)); } }
public ViewResult Create() { var model = new AccountInfoEditModel(); model.FillDropDownLists(); return(View("Create", model)); }
public ViewResult Edit(Guid id) { var model = new AccountInfoEditModel { AccountInfo = _accountInfoService.GetOneAccountInfoById(id) }; model.FillDropDownLists(); return(View(model)); }
public void FailedStorageReturnsRightErrorMessage() { var model = new AccountInfoEditModel { AccountInfo = new AccountInfo { AccountNumber = 3000, AccountName = "testkonto", ResultReportCategory = "Test", IsIncome = "Inntekt" } }; _accountInfoServiceMock.Setup(x => x.SaveOneAccountInfo(model.AccountInfo)).Throws(new Exception()); var result = _subject.Create(model); Assert.That(result.ViewName, Is.EqualTo("Create")); Assert.That(result.ViewData["Message"], Is.EqualTo("Feil i underliggende tjenester under lagring.")); }
public void AllreadyExistsStorageShouldReturnToCreateWithErrorMessage() { var model = new AccountInfoEditModel { AccountInfo = new AccountInfo { AccountNumber = 3000, AccountName = "testkonto", ResultReportCategory = "Test", IsIncome = "Inntekt" } }; _accountInfoServiceMock.Setup(x => x.SaveOneAccountInfo(model.AccountInfo)).Returns(StorageResult.AllreadyExsists); var result = _subject.Create(model); Assert.That(result.ViewName, Is.EqualTo("Create")); Assert.That(result.ViewData["Message"], Is.EqualTo("Kontoinformasjon med samme nummer og år finnes fra før.")); }
public void SuccessfulStorageShouldReturnCreateWithMessage() { var model = new AccountInfoEditModel { AccountInfo = new AccountInfo { AccountNumber = 3000, AccountName = "testkonto", ResultReportCategory = "Test", IsIncome = "Inntekt" } }; _accountInfoServiceMock.Setup(x => x.SaveOneAccountInfo(model.AccountInfo)).Returns(StorageResult.Success); var result = _subject.Create(model); Assert.That(result.ViewName, Is.EqualTo("Create")); Assert.That(result.ViewData["Message"], Is.EqualTo("Kontoinformasjonen er opprettet")); }
public ActionResult Edit(AccountInfoEditModel accountInfoWebWebModel) { if (!ModelState.IsValid) { return(View()); } try { _accountInfoService.UpdateOneAccountInfo(accountInfoWebWebModel.AccountInfo); return(RedirectToAction("Index")); } catch { return(View()); } }
public void SuccessfulStorageShouldReturnCreateWithMessage() { var model = new AccountInfoEditModel { AccountInfo = new AccountInfo { AccountNumber = 3000, AccountName = "testkonto", ResultReportCategory = "Test", IsIncome = "Inntekt"} }; _accountInfoServiceMock.Setup(x => x.SaveOneAccountInfo(model.AccountInfo)).Returns(StorageResult.Success); var result = _subject.Create(model); Assert.That(result.ViewName, Is.EqualTo("Create")); Assert.That(result.ViewData["Message"], Is.EqualTo("Kontoinformasjonen er opprettet")); }
public ViewResult Create() { var model = new AccountInfoEditModel(); model.FillDropDownLists(); return View("Create", model); }
public ActionResult Edit(AccountInfoEditModel accountInfoWebWebModel) { if (!ModelState.IsValid) return View(); try { _accountInfoService.UpdateOneAccountInfo(accountInfoWebWebModel.AccountInfo); return RedirectToAction("Index"); } catch { return View(); } }
public ViewResult Edit(Guid id) { var model = new AccountInfoEditModel { AccountInfo = _accountInfoService.GetOneAccountInfoById(id) }; model.FillDropDownLists(); return View(model); }