Exemplo n.º 1
0
        public ActionResult EditDimensionPopup(string btnId, MeasureDimensionModel model)
        {
            var entity = _measureService.GetMeasureDimensionById(model.Id);

            if (entity == null)
            {
                return(HttpNotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    entity = model.ToEntity(entity);

                    _measureService.UpdateMeasureDimension(entity);

                    if (model.IsPrimaryDimension && _measureSettings.BaseDimensionId != entity.Id)
                    {
                        _measureSettings.BaseDimensionId = entity.Id;
                        Services.Settings.SaveSetting(_measureSettings);
                    }

                    foreach (var localized in model.Locales)
                    {
                        _localizedEntityService.SaveLocalizedValue(entity, x => x.Name, localized.Name, localized.LanguageId);
                    }
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                    return(View(model));
                }

                ViewBag.RefreshPage = true;
                ViewBag.btnId       = btnId;
            }

            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult DimensionAdd([Bind(Exclude = "Id")] MeasureDimensionModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMeasures))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult()
                {
                    Errors = ModelState.SerializeErrors()
                }));
            }

            var dimension = new MeasureDimension();

            dimension = model.ToEntity(dimension);
            _measureService.InsertMeasureDimension(dimension);

            return(new NullJsonResult());
        }
Exemplo n.º 3
0
        public ActionResult DimensionUpdate(MeasureDimensionModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMeasures))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult()
                {
                    Errors = ModelState.SerializeErrors()
                }));
            }

            var dimension = _measureService.GetMeasureDimensionById(model.Id);

            dimension = model.ToEntity(dimension);
            _measureService.UpdateMeasureDimension(dimension);

            return(new NullJsonResult());
        }
        public virtual IActionResult DimensionAdd(MeasureDimensionModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                return(ErrorJson(ModelState.SerializeErrors()));
            }

            var dimension = new MeasureDimension();

            dimension = model.ToEntity(dimension);
            _measureService.InsertMeasureDimension(dimension);

            //activity log
            _customerActivityService.InsertActivity("AddNewMeasureDimension",
                                                    string.Format(_localizationService.GetResource("ActivityLog.AddNewMeasureDimension"), dimension.Id), dimension);

            return(Json(new { Result = true }));
        }
Exemplo n.º 5
0
        public virtual async Task <IActionResult> DimensionUpdate(MeasureDimensionModel model)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageShippingSettings))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                return(ErrorJson(ModelState.SerializeErrors()));
            }

            var dimension = await _measureService.GetMeasureDimensionByIdAsync(model.Id);

            dimension = model.ToEntity(dimension);
            await _measureService.UpdateMeasureDimensionAsync(dimension);

            //activity log
            await _customerActivityService.InsertActivityAsync("EditMeasureDimension",
                                                               string.Format(await _localizationService.GetResourceAsync("ActivityLog.EditMeasureDimension"), dimension.Id), dimension);

            return(new NullJsonResult());
        }
Exemplo n.º 6
0
        public virtual ActionResult DimensionAdd([Bind(Exclude = "Id")] MeasureDimensionModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }

            var dimension = new MeasureDimension();

            dimension = model.ToEntity(dimension);
            _measureService.InsertMeasureDimension(dimension);

            //activity log
            _customerActivityService.InsertActivity("AddNewMeasureDimension", _localizationService.GetResource("ActivityLog.AddNewMeasureDimension"), dimension.Id);

            return(new NullJsonResult());
        }
Exemplo n.º 7
0
        public ActionResult DimensionUpdate(MeasureDimensionModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }

            var dimension = _measureService.GetMeasureDimensionById(model.Id);

            dimension = model.ToEntity(dimension);
            _measureService.UpdateMeasureDimension(dimension);

            //activity log
            _customerActivityService.InsertActivity("EditMeasureDimension", _localizationService.GetResource("ActivityLog.EditMeasureDimension"), dimension.Id);

            return(new NullJsonResult());
        }