private ICollection <FixtureForUpdateDto> GetAllChangedFixture( ICollection <FixtureDto> pastOrCurrentMatchdayFixtures, ICollection <FixtureForUpdateDto> pastOrCurrentMatchdayNotFinishedFixtureInDb) { var updatedFixtureDto = new List <FixtureForUpdateDto>(); foreach (var fixtureinDb in pastOrCurrentMatchdayNotFinishedFixtureInDb) { var fixture = pastOrCurrentMatchdayFixtures .Where(x => x.HomeTeamId == fixtureinDb.HomeTeamId && x.AwayTeamId == fixtureinDb.AwayTeamId) .FirstOrDefault(); if (fixture.Result != fixtureinDb.Result || fixture.Started != fixtureinDb.Started || fixture.Finished != fixtureinDb.Finished) { var fixtureForUpdateDto = new FixtureForUpdateDto { Id = fixtureinDb.Id, AwayTeamId = fixtureinDb.AwayTeamId, HomeTeamId = fixtureinDb.HomeTeamId, Matchday = fixtureinDb.Matchday, Result = fixture.Result, Finished = fixture.Finished, Started = fixture.Started, }; updatedFixtureDto.Add(fixtureForUpdateDto); } } return(updatedFixtureDto); }
public IActionResult Update(FixtureForUpdateDto fixtureForUpdateDto) { var result = fixtureService.Update(fixtureForUpdateDto); if (result.Success) { return(NoContent()); } return(BadRequest(result.Message)); }
public void Update_WhenUpdatedFixture_ShouldUpdate() { // Arrange var fixtureForUpdateDto = new FixtureForUpdateDto(); var mockFixtureDal = new MockFixtureDal().MockUpdate().MockGet(new Fixture()); var sut = new FixtureManager(mockFixtureDal.Object); // Act sut.Update(fixtureForUpdateDto); // Assert mockFixtureDal.VerifyUpdate(Times.Once()); }
public void FixtureForUpdateValidator_WhenPriceLessThanOne_ShouldHaveError() { // Arrange var model = new FixtureForUpdateDto() { Price = 0.8M, }; var sut = new FixtureForUpdateValidator(); // Act var result = sut.TestValidate(model); // Assert result.ShouldHaveValidationErrorFor(m => m.Price); }
public static async Task Update(FixtureForUpdateDto fixtureForUpdateDto) { using var client = new HttpClient(); var uri = $"{APIAddresses.FixtureService}/{fixtureForUpdateDto.Id}"; client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", FormAccessToken.Token); var response = await client.PutAsJsonAsync(uri, fixtureForUpdateDto); if (response.IsSuccessStatusCode) { return; } var errorContent = response.Content.ReadFromJsonAsync <ErrorDetail>().Result; throw new HttpFailureException(errorContent); }
public IResult Update(FixtureForUpdateDto fixtureForUpdateDto) { var fixture = GetById(fixtureForUpdateDto.Id).Data; fixture.CategoryId = fixtureForUpdateDto.CategoryId; fixture.DatePurchase = fixtureForUpdateDto.DatePurchase; fixture.DateWarranty = fixtureForUpdateDto.DateWarranty; fixture.Description = fixtureForUpdateDto.Description; fixture.Name = fixtureForUpdateDto.Name; fixture.PictureUrl = fixtureForUpdateDto.PictureUrl; fixture.Price = fixtureForUpdateDto.Price; fixture.SupplierId = fixtureForUpdateDto.SupplierId; fixture.UpdatedAt = DateTime.Now; fixtureDal.Update(fixture); return(new SuccessResult(Messages.FixtureUpdated)); }
private async Task UpdateFixture() { FixtureForUpdateDto fixtureForUpdateDto = new FixtureForUpdateDto() { Id = _selectedFixtureId, CategoryId = (cmbCategory.SelectedItem as dynamic).Value, DatePurchase = dtpPurchase.Value.Date, DateWarranty = dtpWarranty.Value.Date, Description = txtDescription.Text, Name = txtName.Text, PictureUrl = "pic.lk", // TODO : picture link Price = Convert.ToDecimal(txtPrice.Text), SupplierId = (cmbSupplier.SelectedItem as dynamic).Value }; await FixtureService.Update(fixtureForUpdateDto); MessageBox.Show(Messages.FixtureUpdated); await LoadFixtureList(); }
public void FixtureForUpdateValidator_TrueStory() { // Arrange var model = new FixtureForUpdateDto() { Id = Guid.NewGuid(), CategoryId = 1, DatePurchase = DateTime.Now.AddMinutes(-2), DateWarranty = DateTime.Now.AddYears(2), Description = "Desc Fixture T", Name = "Fixture T", PictureUrl = "picture.lk", Price = 10000M, SupplierId = 1 }; var sut = new FixtureForUpdateValidator(); // Act var result = sut.TestValidate(model); // Assert result.ShouldNotHaveAnyValidationErrors(); }