public async Task <ActionResult <DtoPerson> > Add([FromBody] DtoPerson dtoPerson) { log.LogInformation("Adding person {dtoPerson}", dtoPerson); if (!ModelState.IsValid) { return(BadRequest(getModelStateErrorMessage())); } if (dtoPerson.ID != 0) { return(BadRequest("Cannot add with a valid id")); } if (string.IsNullOrEmpty(dtoPerson.AuthID)) { var person = await personRepository.AddAsync(dtoPerson.Name, dtoPerson.Bio); return(mapper.Map <DtoPerson>(person)); } else { var person = await personRepository.AddAsync(dtoPerson.Name, dtoPerson.Bio, dtoPerson.AuthID); return(mapper.Map <DtoPerson>(person)); } }
public async Task SetUp() { newEvent = await createEvent(); person = await createPerson(); team = await createTeam(person, newEvent.ID); }
public async Task SetUp() { eventController = EventControllerTest.GetEventController(); testEvent = (await eventController.Add(new DtoEvent { Date = new DateTime(1775, 7, 2), Description = "Independence", Location = "Philly", Title = "Sign Here" })).Value; unassignedDonation = new DtoDonation { EventID = testEvent.ID, Amount = 1_000M, Date = new DateTime(1775, 7, 4) }; donationController = GetDonationController(); dtoDonation = (await donationController.Add(unassignedDonation)).Value; var personController = PersonControllerTest.GetPersonController(); team1Owner = (await personController.Add(new DtoPerson { Name = "Team 1 Owner" })).Value; team2Owner = (await personController.Add(new DtoPerson { Name = "Team 2 Owner" })).Value; var teamController = TeamControllerTest.GetTeamController(); team1 = (await teamController.Add(new DtoTeam { Description = "Team1", EventID = testEvent.ID, Name = "Team1", OwnerID = team1Owner.ID })).Value; team2 = (await teamController.Add(new DtoTeam { Description = "Team2", EventID = testEvent.ID, Name = "Team2", OwnerID = team2Owner.ID })).Value; team1Donations = new[] { createDonation(testEvent.ID, team1.ID, 100), createDonation(testEvent.ID, team1.ID, 200) }; team2Donations = new[] { createDonation(testEvent.ID, team2.ID, 300), createDonation(testEvent.ID, team2.ID, 400) }; foreach (var donation in team1Donations.Union(team2Donations)) { await donationController.Add(donation); } }
private DtoPersonModify ModifyPerson(DtoPerson person) { return(new DtoPersonModify() { Name = person.Name, Region_code = person.Region_code, PartnerId = person.PartnerId, FavoriteId = person.FavoriteId, }); }
public async Task CanGetDifferentPerson() { var newPerson = new DtoPerson { Name = "Ben" }; var createdPerson = (await GetPersonController().Add(newPerson)).Value; var returnedPerson = (await GetPersonController().GetByID(createdPerson.ID)).Value; returnedPerson.Name.Should().Be("Ben"); }
public static DtoPerson WithAuthID(this DtoPerson currentPerson, string newAuthId) { return(new DtoPerson { Name = currentPerson.Name, ID = currentPerson.ID, Bio = currentPerson.Bio, AuthID = newAuthId, }); }
public async Task CanCreatePerson() { var newPerson = new DtoPerson { Name = "George" }; var dtoPerson = (await GetPersonController().Add(newPerson)).Value; dtoPerson.ID.Should().NotBe(0); dtoPerson.Name.Should().Be("George"); }
public void GivenIWantToCreateAPersonWithTheFollowingInformation(Table table) { var row = table.Rows[0]; var dtoPerson = new DtoPerson { Name = row["Name"], Bio = row["Bio"] }; scenarioContext.Set(dtoPerson, "personToCreate"); }
public async Task PersonCanBeCreatedWithAuthId() { var newPerson = new DtoPerson { Name = "Bill", AuthID = Guid.NewGuid().ToString() }; var createdPerson = (await GetPersonController().Add(newPerson)).Value; var returnedPerson = (await GetPersonController().GetByID(createdPerson.ID)).Value; returnedPerson.AuthID.Should().Be(newPerson.AuthID); }
public async Task GetPersonByAuthId() { var authId = Guid.NewGuid().ToString(); var newPerson = new DtoPerson { Name = "Bill", AuthID = authId }; var createdPerson = (await GetPersonController().Add(newPerson)).Value; var returnedPerson = (await GetPersonController().GetByAuthId(authId)).Value; returnedPerson.AuthID.Should().Be(newPerson.AuthID); }
public async Task CanAddAuthIdToPersonAfterCreation() { var newPerson = new DtoPerson { Name = "Mike" }; var createdPerson = (await GetPersonController().Add(newPerson)).Value; var authIdPerson = createdPerson.WithAuthID(Guid.NewGuid().ToString()); await GetPersonController().Edit(authIdPerson); var returnedPerson = (await GetPersonController().GetByID(createdPerson.ID)).Value; returnedPerson.AuthID.Should().Be(authIdPerson.AuthID); }
public async Task CanDeletePerson() { var newPerson = new DtoPerson { Name = "Ben" }; var createdPerson = (await GetPersonController().Add(newPerson)).Value; await GetPersonController().Delete(createdPerson.ID); var badPersonRequests = await GetPersonController().GetByID(createdPerson.ID); var actual = badPersonRequests.Result as NotFoundObjectResult; actual.StatusCode.Should().Be(404); }
public async Task CanEditPerson() { var newPerson = new DtoPerson { Name = "Ben" }; var createdPerson = (await GetPersonController().Add(newPerson)).Value; var person = TestHelpers.AspenMapper.Map <Person>(createdPerson); var editedPerson = person.WithName("notBen").WithBio("new bio"); await GetPersonController().Edit(TestHelpers.AspenMapper.Map <DtoPerson>(editedPerson)); var returnedPerson = (await GetPersonController().GetByID(createdPerson.ID)).Value; returnedPerson.Name.Should().Be(editedPerson.Name); }
public void SendNotification(DtoPerson person, string text) { lock (_locker) { if (_coordinator == null) { _coordinator = _system.ActorOf(Props.Create(() => new ActorCoordinator(_serviceScopeFactory)), "SendersCoordinator"); } } _coordinator.Tell(new DtoNotification { Person = person, Text = text }); }
public async Task <ActionResult <DtoPerson> > Edit([FromBody] DtoPerson dtoPerson) { log.LogInformation("Editing person {dtoPerson}", dtoPerson); if (!ModelState.IsValid) { return(BadRequest(getModelStateErrorMessage())); } if (!await personRepository.ExistsAsync(dtoPerson.ID)) { return(NotFound("Person id does not exist")); } var person = mapper.Map <Person>(dtoPerson); var updatedPerson = await personRepository.EditAsync(person); return(mapper.Map <DtoPerson>(updatedPerson)); }
public async Task <DtoPerson> CreatePersonAsync(DtoPerson person) { var request = new RestRequest("api/person/").AddJsonBody(person); return(await Client.PostAsync <DtoPerson>(request)); }
public void UpdateData(DtoPerson person) { NameText.text = person.ShortName; HpText.text = "HP: " + person.HP + "/" + person.MaxHP; DmgText.text = "Dmg: " + (int)(person.Damage * 0.5f) + "-" + (int)(person.Damage * 1.5f); }
private async Task <DtoRegistration> createRegistration(DtoPerson owner, DtoTeam team) => (await RegistrationControllerTest.GetRegistrationController().Add(new DtoRegistration { Nickname = "Reg1", OwnerID = owner.ID, TeamID = team.ID })).Value;
private async Task <DtoTeam> createTeam(DtoPerson person, long eventId) => (await TeamControllerTest.GetTeamController().Add(new DtoTeam { Name = "New Team Name", Description = "Team1", OwnerID = person.ID, EventID = eventId })).Value;