Ejemplo n.º 1
0
        public ActionResult UpdateCategoryAjax([FromBody] CategoryModelForPost categoryModel)
        {
            if (!_workContext.CurrentCustomer.IsRegistered())
            {
                return(Unauthorized());
            }


            if (!_workContext.CurrentCustomer.IsInCustomerRole(RolesType.Administrators, true) && !_workContext.CurrentCustomer.IsInCustomerRole(RolesType.ConsultationAdmin, true))
            {
                return(Forbid());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var category = _category.UpdateCategory(categoryModel);

            if (category == null)
            {
                return(Json(new { result = false }));
            }

            return(Json(new { result = true }));
        }
Ejemplo n.º 2
0
        //Add Category
        public ActionResult UpdateCategory(int catId)
        {
            if (!_workContext.CurrentCustomer.IsRegistered())
            {
                return(Unauthorized());
            }

            if (!_workContext.CurrentCustomer.IsInCustomerRole(RolesType.Administrators, true) && !_workContext.CurrentCustomer.IsInCustomerRole(RolesType.ConsultationAdmin, true))
            {
                return(Forbid());
            }

            var cat = _category.GetCategory(catId);

            var model = new CategoryModelForPost()
            {
                Id          = cat.Id,
                Name        = cat.Name,
                Description = cat.Description,
                IsActive    = cat.IsActive
            };

            return(View("~/Themes/Pavilion/Views/ConsultantAdmin/Categories/UpdateCategory.cshtml", model));
        }