Beispiel #1
0
        public ActionResult Create(CataloguesModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalogues))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var catalogues = model.ToEntity();
                catalogues.CreatedOnUtc = DateTime.UtcNow;
                catalogues.UpdatedOnUtc = DateTime.UtcNow;
                _cataloguesService.InsertCatalogues(catalogues);
                //search engine name
                model.SeName = catalogues.ValidateSeName(model.SeName, catalogues.Name, true);
                _urlRecordService.SaveSlug(catalogues, model.SeName, 0);
                //locales
                UpdateLocales(catalogues, model);

                //update picture seo file name
                UpdatePictureSeoNames(catalogues);
                //ACL (customer roles)
                SaveCataloguesAcl(catalogues, model);


                //activity log
                _customerActivityService.InsertActivity("AddNewCatalogues", _localizationService.GetResource("ActivityLog.AddNewCatalogues"), catalogues.Name);

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

            //If we got this far, something failed, redisplay form

            //catalogues
            PrepareAllCataloguesModel(model);

            //ACL
            PrepareAclModel(model, null, true);

            return(View(model));
        }
        public ActionResult Edit(CataloguesModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalogues))
                return AccessDeniedView();

            var catalogues = _cataloguesService.GetCatalogueById(model.Id);
            if (catalogues == null || catalogues.Deleted)
                //No catalogues found with the specified id
                return RedirectToAction("List");

            if (ModelState.IsValid)
            {
                int prevPictureId = catalogues.PictureId;
                catalogues = model.ToEntity(catalogues);
                catalogues.UpdatedOnUtc = DateTime.UtcNow;
                _cataloguesService.UpdateCatalogues(catalogues);
                //search engine name
                model.SeName = catalogues.ValidateSeName(model.SeName, catalogues.Name, true);
                _urlRecordService.SaveSlug(catalogues, model.SeName, 0);
                //locales
                UpdateLocales(catalogues, model);

                _cataloguesService.UpdateCatalogues(catalogues);

                //delete an old picture (if deleted or updated)
                if (prevPictureId > 0 && prevPictureId != catalogues.PictureId)
                {
                    var prevPicture = _pictureService.GetPictureById(prevPictureId);
                    if (prevPicture != null)
                        _pictureService.DeletePicture(prevPicture);
                }
                //update picture seo file name
                UpdatePictureSeoNames(catalogues);
                //ACL
                SaveCataloguesAcl(catalogues, model);

                //activity log
                _customerActivityService.InsertActivity("EditCatalogues", _localizationService.GetResource("ActivityLog.EditCatalogues"), catalogues.Name);

                SuccessNotification(_localizationService.GetResource("Admin.News.Catalogues.Updated"));
                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabIndex();

                    return RedirectToAction("Edit", catalogues.Id);
                }
                return RedirectToAction("List");
            }

            //If we got this far, something failed, redisplay form

            //catalogues
            PrepareAllCataloguesModel(model);
            //ACL
            PrepareAclModel(model, catalogues, true);

            return View(model);
        }
        public ActionResult Create(CataloguesModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalogues))
                return AccessDeniedView();

            if (ModelState.IsValid)
            {
                var catalogues = model.ToEntity();
                catalogues.CreatedOnUtc = DateTime.UtcNow;
                catalogues.UpdatedOnUtc = DateTime.UtcNow;
                _cataloguesService.InsertCatalogues(catalogues);
                //search engine name
                model.SeName = catalogues.ValidateSeName(model.SeName, catalogues.Name, true);
                _urlRecordService.SaveSlug(catalogues, model.SeName, 0);
                //locales
                UpdateLocales(catalogues, model);

                //update picture seo file name
                UpdatePictureSeoNames(catalogues);
                //ACL (customer roles)
                SaveCataloguesAcl(catalogues, model);

                //activity log
                _customerActivityService.InsertActivity("AddNewCatalogues", _localizationService.GetResource("ActivityLog.AddNewCatalogues"), catalogues.Name);

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

            //If we got this far, something failed, redisplay form

            //catalogues
            PrepareAllCataloguesModel(model);

            //ACL
            PrepareAclModel(model, null, true);

            return View(model);
        }
Beispiel #4
0
        public ActionResult Edit(CataloguesModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalogues))
            {
                return(AccessDeniedView());
            }

            var catalogues = _cataloguesService.GetCatalogueById(model.Id);

            if (catalogues == null || catalogues.Deleted)
            {
                //No catalogues found with the specified id
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                int prevPictureId = catalogues.PictureId;
                catalogues = model.ToEntity(catalogues);
                catalogues.UpdatedOnUtc = DateTime.UtcNow;
                _cataloguesService.UpdateCatalogues(catalogues);
                //search engine name
                model.SeName = catalogues.ValidateSeName(model.SeName, catalogues.Name, true);
                _urlRecordService.SaveSlug(catalogues, model.SeName, 0);
                //locales
                UpdateLocales(catalogues, model);

                _cataloguesService.UpdateCatalogues(catalogues);

                //delete an old picture (if deleted or updated)
                if (prevPictureId > 0 && prevPictureId != catalogues.PictureId)
                {
                    var prevPicture = _pictureService.GetPictureById(prevPictureId);
                    if (prevPicture != null)
                    {
                        _pictureService.DeletePicture(prevPicture);
                    }
                }
                //update picture seo file name
                UpdatePictureSeoNames(catalogues);
                //ACL
                SaveCataloguesAcl(catalogues, model);

                //activity log
                _customerActivityService.InsertActivity("EditCatalogues", _localizationService.GetResource("ActivityLog.EditCatalogues"), catalogues.Name);

                SuccessNotification(_localizationService.GetResource("Admin.News.Catalogues.Updated"));
                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabIndex();

                    return(RedirectToAction("Edit", catalogues.Id));
                }
                return(RedirectToAction("List"));
            }


            //If we got this far, something failed, redisplay form

            //catalogues
            PrepareAllCataloguesModel(model);
            //ACL
            PrepareAclModel(model, catalogues, true);

            return(View(model));
        }