Ejemplo n.º 1
0
        public ActionResult LoadTrainingBoxes(int id, BillingEnums.ePurchaseItemTypes type, bool isVeiwer = false)
        {
            var token = _trainingServices.GetTrainingBoxesDto(id, type);

            token.IsInViewer = isVeiwer;
            return(PartialView("Training/_LiveSessionBoxes", token));
        }
Ejemplo n.º 2
0
        public JsonResult GetItemDetails(int id, BillingEnums.ePurchaseItemTypes type)
        {
            string error;
            var    token = _courseServices.GetBaseItemListDto(id, type, out error);

            return(Json(new JsonResponseToken
            {
                success = token != null
                , result = token
                , error = error
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public ActionResult LoadUserTrainingForm(int id, BillingEnums.ePurchaseItemTypes type)
        {
            var registrations = _trainingServices.GetItemTrainingUserRegistrtions(CurrentUserId, id, type);

            if (registrations.Count == 0 || registrations.All(x => x.RegistrantStatus == TrainingEnums.eTrainingStatus.CANCEL))
            {
                var token = _trainingServices.GetTrainingUserRegisterDto(id, type);
                token.Item = new BaseItemToken {
                    ItemId = id, ItemType = type
                };
                return(PartialView("Training/_UserRegister", token));
            }

            var registration = registrations.Where(x => x.RegistrantStatus == TrainingEnums.eTrainingStatus.REGISTERED).OrderBy(x => x.Start).First();

            return(PartialView("Training/_UserCountdown", registration));
        }
Ejemplo n.º 4
0
        public ActionResult GetItemPriceWithCoupon(int lineId, int ownerId, int itemId, string couponCode, BillingEnums.ePurchaseItemTypes itemType)
        {
            int?courseId = null;
            int?bundleId = null;

            switch (itemType)
            {
            case BillingEnums.ePurchaseItemTypes.COURSE:
                courseId = itemId;
                break;

            case BillingEnums.ePurchaseItemTypes.BUNDLE:
                bundleId = itemId;
                break;
            }

            var checkResult = _couponWidgetServices.ValidateCoupon(lineId, ownerId, courseId, bundleId, couponCode);

            return(Json(checkResult, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
 public static string StoreItemName2DisplayName(this string name, BillingEnums.ePurchaseItemTypes type)
 {
     return(String.Format("{0} {1}", type == BillingEnums.ePurchaseItemTypes.COURSE ? string.Empty : "(Bundle)", name));
 }
Ejemplo n.º 6
0
        public static string GenerateItemFullPageUrl(this object obj, string author, string itemName, BillingEnums.ePurchaseItemTypes type, string trackingId = null, string mode = null, int?width = null, int?height = null)
        {
            var relative = itemName.GenerateItemPageUrl(author, itemName, type, trackingId);

            if (String.IsNullOrEmpty(relative))
            {
                return(string.Empty);
            }

            return("baseUrl".GetKeyValue() + relative.Remove(0, 1));
        }
Ejemplo n.º 7
0
        public static string GenerateItemPageUrl(this object obj, string author, string itemName, BillingEnums.ePurchaseItemTypes type, string trackingId = null, string mode = null, int?width = null, int?height = null, string compId = null)
        {
            var url = new UrlHelper(HttpContext.Current.Request.RequestContext);

            var routeName = "Widget_";

            switch (type)
            {
            case BillingEnums.ePurchaseItemTypes.COURSE:
                routeName += String.Format("{0}Course", String.IsNullOrEmpty(trackingId) ? string.Empty : "Store");
                break;

            case BillingEnums.ePurchaseItemTypes.BUNDLE:
                routeName += String.Format("{0}Bundle", String.IsNullOrEmpty(trackingId) ? string.Empty : "Store");
                break;

            default:
                return(string.Empty);
            }

            //Widget_StoreCourse
            //Widget_Course
            //Widget_StoreBundle
            //Widget_Bundle

            var dict = new RouteValueDictionary
            {
                { "type", type },
                { "author", author.CleanUrl() },
                { "itemName", itemName.CleanUrl() },
                { "trackingId", String.IsNullOrEmpty(trackingId) ? "" : trackingId.CleanQsParamValue() }
            };

            if (!String.IsNullOrEmpty(mode))
            {
                dict.Add("mode", mode);
            }
            if (width != null)
            {
                dict.Add("width", width.ToString().CleanQsParamValue());
            }
            if (height != null)
            {
                dict.Add("height", height.ToString().CleanQsParamValue());
            }
            if (!String.IsNullOrEmpty(compId))
            {
                dict.Add("compId", compId.CleanQsParamValue());
            }

            var routeUrl = url.RouteUrl(routeName, dict);

            return(routeUrl);
        }
Ejemplo n.º 8
0
        //[CacheFilter(Duration = 60)]
        public ActionResult Index(BillingEnums.ePurchaseItemTypes type, string author, string itemName, string trackingId, string mode = null, int?width = null, int?height = null)
        {
            var item = WidgetServices.FindItemByUrlName(author, itemName, type);

            if (!item.IsValid)
            {
                return(View("ItemNotFound", item));
            }

            #region ViewBag settings

            try
            {
                ViewBag.BackgroundColor = "#FFFFFF";
                if (MainLayoutViewModel != null)
                {
                    if (MainLayoutViewModel.WebStore != null && !string.IsNullOrEmpty(MainLayoutViewModel.WebStore.BackgroundColor))
                    {
                        ViewBag.BackgroundColor = MainLayoutViewModel.WebStore.BackgroundColor;
                    }

                    if (!string.IsNullOrEmpty(Request.QueryString["_escaped_fragment_"]))
                    {
                        ViewBag.TabName = Request.QueryString["_escaped_fragment_"];
                    }

                    if (width != null)
                    {
                        MainLayoutViewModel.Width = width;
                    }
                    if (height != null)
                    {
                        MainLayoutViewModel.Height = height;
                    }
                }
                else
                {
                    MainLayoutViewModel = new BaseModelViewToken
                    {
                        WebStore              = null
                        , CategoriesList      = new List <WidgetCategoryDTO>()
                        , IsValid             = true
                        , IsSingleCourseStore = true
                        , TrackingId          = trackingId
                    };

                    ViewData["MainLayoutViewModel"] = MainLayoutViewModel;
                    TempData["MainLayoutViewModel"] = MainLayoutViewModel;
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Item page ViewBag::" + itemName + "::" + author + "::" + trackingId, ex, CommonEnums.LoggerObjectTypes.Widget);
            }

            #endregion


            var itemState = WidgetServices.GetItemAccessState4User(CurrentUserId, item.ItemId, item.ItemType);

            itemState.IsPreview = (!String.IsNullOrEmpty(mode) && mode == Constants.QS_COURSE_PREVIEW_PREFIX);

            var loadViewer = !itemState.IsPreview && (itemState.IsOwnedByUser || (itemState.IsAccessAllowed && itemState.IsPublished) || (mode == Constants.QS_COURSE_ADMIN_PREVIEW_PREFIX && this.IsCurrentUserAdmin()));

            var token = WidgetServices.ItemInfoToken2ItemViewerPageToken(item, itemState, trackingId);

            if (loadViewer)
            {
                return(View("ItemViewer", token));
            }

            return(itemState.IsPublished || (itemState.IsPreview && itemState.IsOwnedByUser) ? View("ProductPage", WidgetServices.ItemInfoToken2ItemProductPageToken(item, itemState, trackingId)) : View("ItemNotPublished"));

            // var url = Url.ActionString("ItemNotPublished","Item",new RouteValueDictionary{{"area","Widget"}});

            //return Redirect(url);
        }
Ejemplo n.º 9
0
 public static int?ItemViewerToken2ItemId(this ItemViewerPageToken token, BillingEnums.ePurchaseItemTypes type)
 {
     return(token.ItemType == type ? token.ItemId : (int?)null);
 }