Beispiel #1
0
        public bool CreateSubscriptionAddToCart(SubscriptionType type)
        {
            SubscriptionTypeLogic typeLOgic = new SubscriptionTypeLogic();
            SubscriptionType      subType   = typeLOgic.CreateSubscriptionWithProduct(type);

            if (subType == null && String.IsNullOrEmpty(typeLOgic.ErrorMessage))
            {
                ErrorMessage = typeLOgic.ErrorMessage;
            }
            else
            {
                CartItem item = new CartItem()
                {
                    SubscriptionTypeId = subType.Id,
                    DateCreated        = DateTime.Now.Date,
                    Quantity           = 1,
                    UserId             = type.CreatedBy,
                    Price = subType.Price
                };
                CartLogic logic  = new CartLogic();
                var       status = logic.CreateCartItem(item);
                if (!status)
                {
                    ErrorMessage = logic.ErrorMessage;
                }
            }
            return(String.IsNullOrEmpty(ErrorMessage));
        }
Beispiel #2
0
        public HttpResponseMessage CreateCart(CartItem item)
        {
            bool status = logic.CreateCartItem(item);

            if (status)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, "Success"));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, logic.ErrorMessage));
            }
        }
        public void AddCartItem()
        {
            var sub = subTypeLogic.GetSubscriptionType();

            if (sub.Count > 0)
            {
                var obj = sub.FirstOrDefault(s => s.Name == "Sub1");
                var subscriptioinTypeId = obj.Id;
                var status = cartLogic.CreateCartItem(new CartItem()
                {
                    Quantity = 2, SubscriptionTypeId = subscriptioinTypeId, UserId = usr.UserId, DateCreated = DateTime.Now.Date, Price = 2 * obj.Price
                });
                Assert.IsTrue(status);
            }
            else
            {
                Assert.Fail("Subscription Type does not exist");
            }
        }