public void can_update_donator_entry() { var donator = new DonatorBuilder() .With(d => d.Id, 123) .With(d => d.PatreonName, "Jimmybob") .With(d => d.Tier, 1) .With(d => d.ActualDonationAmount, 1) .BuildAndSave(); var user = new UserBuilder() .With(d => d.Donator, donator) .BuildAndSave(); var cmd = new UpdateDonator() { UserId = user.Id, ActualDonationAmount = 9, PatreonName = "Jimmybob the second", Tier = 3, SpecialNotes = "good boy!" }; Assert.That(() => DomainRegistry.Repository.Execute(cmd), Throws.Nothing); Assert.That(DataContext.AsQueryable <Donator>().Where(d => d.PatreonName == "Jimmybob the second" && d.ActualDonationAmount == 9 && d.Tier == 3 && d.SpecialNotes == "good boy!"), Has.Exactly(1).Items); }
public void should_throw_error_if_user_not_found() { var cmd = new UpdateDonator { UserId = "fakeuser", ActualDonationAmount = 9, PatreonName = "Bob", Tier = 3 }; Assert.That(() => Repository.Execute(cmd), Throws.TypeOf <DomainException>().With.Message.EqualTo("User 'fakeuser' could not be found")); }
public void should_require_user() { var cmd = new UpdateDonator { UserId = null, ActualDonationAmount = 9, PatreonName = "Bob", Tier = 3 }; Assert.That(() => Repository.Execute(cmd), Throws.TypeOf <DomainException>().With.Message.EqualTo("userId is required")); }
public virtual ActionResult EditSend(UpdateDonator input) { input.UserId = input.UserId.Trim(); input.PatreonName = input.PatreonName.Trim(); try { DomainRegistry.Repository.Execute(input); DomainRegistry.Repository.Execute(new ChangeDonatorTier { UserId = input.UserId, Tier = input.Tier }); TempData["Result"] = "Donator update successful."; } catch (DomainException e) { TempData["Error"] = "Error: " + e.Message; } return(RedirectToAction(MVC.Donator.List())); }
public void UpdateDonator(UpdateDonator cmd) { this.Donator.Update(cmd.PatreonName, cmd.Tier, cmd.ActualDonationAmount, cmd.SpecialNotes); }