Пример #1
0
        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));
        }
Пример #2
0
        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));
        }
Пример #3
0
        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);
        }
Пример #4
0
 public async Task <Loyalty> UpdateAsync(LoyaltyUpdateModel loyalty)
 {
     return(await this.LoyaltyDAL.UpdateAsync(loyalty));
 }