public async Task <BarbershopWebApp.Domain.Loyalty> InsertAsync(LoyaltyUpdateModel loyalty) { var result = await this.Context.AddAsync(this.Mapper.Map <Loyalty>(loyalty)); await this.Context.SaveChangesAsync(); return(this.Mapper.Map <BarbershopWebApp.Domain.Loyalty>(result.Entity)); }
public async Task <BarbershopWebApp.Domain.Loyalty> UpdateAsync(LoyaltyUpdateModel loyalty) { var existing = await this.Get(loyalty); var result = this.Mapper.Map(loyalty, existing); this.Context.Update(result); await this.Context.SaveChangesAsync(); return(this.Mapper.Map <BarbershopWebApp.Domain.Loyalty>(result)); }
public async Task CreateAsync_loyaltyValidationSucceed_Createsloyalty() { // Arrange var loyalty = new LoyaltyUpdateModel(); var expected = new Loyalty(); var loyaltyDAL = new Mock <ILoyaltyDAL>(); loyaltyDAL.Setup(x => x.InsertAsync(loyalty)).ReturnsAsync(expected); var loyaltyService = new LoyaltyService(loyaltyDAL.Object); // Act var result = await loyaltyService.CreateAsync(loyalty); // Assert result.Should().Be(expected); }
public async Task <Loyalty> UpdateAsync(LoyaltyUpdateModel loyalty) { return(await this.LoyaltyDAL.UpdateAsync(loyalty)); }