public ClientSubscription ThirdClientSubscription()
 {
     var thirdClientSubscription = new ClientSubscription
     {
         ClientSubscriptionId = 3,
         ClientId = 2,
         CookerSubscriptionId = 1,
         Active = false,
         ValidUntil = DateTime.Today.AddMonths(-1).Date
     };
     return thirdClientSubscription;
 }
 public ClientSubscription SecondClientSubscription()
 {
     var secondClientSubscription = new ClientSubscription
     {
         ClientSubscriptionId = 2,
         ClientId = 1,
         CookerSubscriptionId = 3,
         Active = true,
         ValidUntil = DateTime.Today.AddMonths(12).Date
     };
     return secondClientSubscription;
 }
 public ClientSubscription FirstClientSubscription()
 {
     var firstClientSubscription = new ClientSubscription
     {
         ClientSubscriptionId = 1,
         ClientId = 1,
         CookerSubscriptionId = 1,
         Active = true,
         ValidUntil = DateTime.Today.AddMonths(1).Date
     };
     return firstClientSubscription;
 }
Пример #4
0
        private Invoice GenerateInvoiceForSubscription(ClientSubscription newClientSubscription)
        {
            var orderSubscription = CreateSubscriptionOrder(newClientSubscription);
            _uow.OrderSubscriptionRepository.Add(orderSubscription);
            _uow.Save();
            var orderSubscriptionInvoice = CreateSubscriptionInvoice(orderSubscription);
            Assert.AreEqual(orderSubscriptionInvoice.Total, (decimal)16.21);

            return orderSubscriptionInvoice;
        }
Пример #5
0
        private OrderSubscription CreateSubscriptionOrder(ClientSubscription newClientSubscription)
        {
            var cookerServingPriceModel = new SubscriptionHelper(_uow).GetCookerServingPriceModel(newClientSubscription.ClientSubscriptionId);
            var subscriptionOrder = new OrderSubscription
            {
                OrderSubscriptionId = _uow.OrderSubscriptionItemRepository.All.ToList().Max(x => x.OrderSubscriptionId) + 1,
                ClientId = newClientSubscription.ClientId,
                OrderDate = DateTime.Today.Date,
                DeliveryDate = null,
                OrderTypeId = (int)OrderType.Values.NotSet,
                PaymentMethodId = (int)PaymentMethodType.Values.NotSet,
                CouponId = null,
                PromotionId = null,
                PlanId = cookerServingPriceModel.PLanId,
                SubTotal = cookerServingPriceModel.Price,
                CurrencyId = (int)CurrencyType.Values.Usd,
                OrderStatusId = (int)OrderStatus.Values.InProgress,
                ServingMeasurementId = cookerServingPriceModel.ServingMeasurementId,
                NumberofServingTotal = 4 * cookerServingPriceModel.Quantity,
                ClientSubscriptionId = newClientSubscription.ClientSubscriptionId
            };

            #region WeeksSubscriptionItems

            #region Week1
            subscriptionOrder.OrderSubscriptionItems.Add(MostPopularDishFromCooker1MenuSubscriptionItem((int)WeekType.Values.Week1));
            #endregion

            #region Week2
            subscriptionOrder.OrderSubscriptionItems.Add(MostPopularDishFromCooker1MenuSubscriptionItem((int)WeekType.Values.Week2));
            #endregion

            #region Week3
            subscriptionOrder.OrderSubscriptionItems.Add(MostPopularDishFromCooker1MenuSubscriptionItem((int)WeekType.Values.Week3));

            #endregion

            #region Week4
            subscriptionOrder.OrderSubscriptionItems.Add(MostPopularDishFromCooker1MenuSubscriptionItem((int)WeekType.Values.Week4));
            #endregion

            #endregion

            _uow.OrderSubscriptionRepository.Add(subscriptionOrder);
            _uow.Save();
            return subscriptionOrder;
        }
Пример #6
0
        private ClientSubscription ClientSubscribeToCookerSubscription()
        {
            var cookerSubscriptionCount = _uow.CookerSubscriptionRepository.All.Count();
            var clientSubscriptionCount = _uow.ClientSubscriptionRepository.All.Count();
            Assert.AreEqual(clientSubscriptionCount, 3);
            Assert.AreEqual(cookerSubscriptionCount, 3);

            #region GIVEN

            #region CookerSubscriptionDetailInformation

            //Cooker Subscription is the following:
            //var secondCookerSubscription = new CookerSubscription
            //{
            //    CookerSubscriptionId = 2,
            //    CookerId = 1,
            //    PlanId = (int)LookUp.Plans.Plans.Types.FiveMealsPerWeek,
            //    ServingPriceId = (int)ServingPriceModel.Values.Fourteen_Dollars_NintyNine
            //};

            #endregion

            #region Client Information

            //var secondClient = new Client
            //{
            //    ClientId = 2,
            //    UserId = 4
            //};

            //   var fourthUser = new User
            //{
            //    UserId = 4,
            //    FirstName = "Robert",
            //    LastName = "Lone",
            //    EmailAddress = "*****@*****.**",
            //    UserTypeId = (int)UserTypes.Values.Client,
            //    Photo = @"C:\Users\haraissia\AndroidStudioProjects\android-topeka\app\build\intermediates\res\debug\drawable-xxxhdpi\avatar_2_raster.png",
            //    Bio = "I love good and healthy food too",
            //    CountryId = 1,
            //    RegionId = 1,
            //    CityId = 1,
            //    ZipCode = "66216",
            //    Address = "6102 Plumb Road",
            //    AddressTypeId = (int)AddressType.Values.Home,
            //    PhoneNumber = "9134060298"
            //};

            #endregion

            #endregion

            var robertSubscriptionCount = _uow.ClientSubscriptionRepository.Count(x => x.ClientId == 2);
            Assert.AreEqual(robertSubscriptionCount, 1);

            var newClientSubscription = new ClientSubscription
            {
                //ClientSubscriptionId = 1,
                ClientSubscriptionId = _uow.ClientSubscriptionRepository.All.ToList().Max(x => x.ClientSubscriptionId) + 1,
                ClientId = 2,
                CookerSubscriptionId = 2,
                Active = true,
                ValidUntil = DateTime.Today.AddMonths(1).Date,
                Recurring = false
            };
            _uow.ClientSubscriptionRepository.Add(newClientSubscription);
            _uow.Save();

            Assert.AreEqual(robertSubscriptionCount + 1, _uow.ClientSubscriptionRepository.Count(x => x.ClientId == 2));
            return newClientSubscription;
        }