Exemplo n.º 1
0
        public async Task <IActionResult> Create(CourseModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                if (_workContext.CurrentCustomer.IsStaff())
                {
                    model.LimitedToStores  = true;
                    model.SelectedStoreIds = new string[] { _workContext.CurrentCustomer.StaffStoreId };
                }

                var course = await _courseViewModelService.InsertCourseModel(model);

                SuccessNotification(_localizationService.GetResource("Admin.Courses.Course.Added"));
                return(continueEditing ? RedirectToAction("Edit", new { id = course.Id }) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            model = await _courseViewModelService.PrepareCourseModel(model);

            //ACL
            await model.PrepareACLModel(null, true, _customerService);

            ////Stores
            await model.PrepareStoresMappingModel(null, _storeService, true, _workContext.CurrentCustomer.StaffStoreId);

            return(View(model));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create(CourseModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                if (await _groupService.IsStaff(_workContext.CurrentCustomer))
                {
                    model.Stores = new string[] { _workContext.CurrentCustomer.StaffStoreId };
                }

                var course = await _courseViewModelService.InsertCourseModel(model);

                Success(_translationService.GetResource("Admin.Courses.Course.Added"));
                return(continueEditing ? RedirectToAction("Edit", new { id = course.Id }) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            model = await _courseViewModelService.PrepareCourseModel(model);

            return(View(model));
        }