public ActionResult CreateWeightPopup(string btnId, MeasureWeightModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var entity = model.ToEntity();

                    _measureService.InsertMeasureWeight(entity);

                    if (model.IsPrimaryWeight)
                    {
                        _measureSettings.BaseWeightId = 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));
        }
예제 #2
0
        public virtual IActionResult WeightUpdate(MeasureWeightModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(AccessDeniedView());
            }

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

            var weight = _measureService.GetMeasureWeightById(model.Id);

            weight = model.ToEntity(weight);
            _measureService.UpdateMeasureWeight(weight);

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

            return(new NullJsonResult());
        }
        public async Task <IActionResult> WeightUpdate(MeasureWeightModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }

            var weight = await _measureService.GetMeasureWeightById(model.Id);

            weight = model.ToEntity(weight);
            await _measureService.UpdateMeasureWeight(weight);

            return(new NullJsonResult());
        }
        public IActionResult WeightAdd(MeasureWeightModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }

            var weight = new MeasureWeight();

            weight = model.ToEntity(weight);
            _measureService.InsertMeasureWeight(weight);

            return(new NullJsonResult());
        }
예제 #5
0
        public ActionResult WeightAdd([Bind(Exclude = "Id")] MeasureWeightModel model, GridCommand command)
        {
            if (_permissionService.Authorize(StandardPermissionProvider.ManageMeasures))
            {
                if (!ModelState.IsValid)
                {
                    var modelStateErrors = this.ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage);
                    return(Content(modelStateErrors.FirstOrDefault()));
                }

                var weight = new MeasureWeight();
                weight = model.ToEntity(weight);

                _measureService.InsertMeasureWeight(weight);
            }

            return(Weights(command));
        }
예제 #6
0
        public ActionResult WeightUpdate(MeasureWeightModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMeasures))
            {
                return(AccessDeniedView());
            }

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

            var weight = _measureService.GetMeasureWeightById(model.Id);

            weight = model.ToEntity(weight);
            _measureService.UpdateMeasureWeight(weight);

            return(new NullJsonResult());
        }
예제 #7
0
        public ActionResult WeightAdd([Bind(Exclude = "Id")] MeasureWeightModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMeasures))
            {
                return(AccessDeniedView());
            }

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

            var weight = new MeasureWeight();

            weight = model.ToEntity(weight);
            _measureService.InsertMeasureWeight(weight);

            return(new NullJsonResult());
        }
예제 #8
0
        public ActionResult WeightUpdate(MeasureWeightModel model, GridCommand command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMeasures))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                //display the first model error
                var modelStateErrors = this.ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage);
                return(Content(modelStateErrors.FirstOrDefault()));
            }

            var weight = _measureService.GetMeasureWeightById(model.Id);

            weight = model.ToEntity(weight);
            _measureService.UpdateMeasureWeight(weight);

            return(Weights(command));
        }
예제 #9
0
        public ActionResult WeightAdd([Bind(Exclude = "Id")] MeasureWeightModel model, GridCommand command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMeasures))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                return(new JsonResult {
                    Data = "error"
                });
            }

            var weight = new MeasureWeight();

            weight = model.ToEntity(weight);
            _measureService.InsertMeasureWeight(weight);

            return(Weights(command));
        }
예제 #10
0
        public ActionResult WeightUpdate(MeasureWeightModel model, GridCommand command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMeasures))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                return(new JsonResult {
                    Data = "error"
                });
            }

            var weight = _measureService.GetMeasureWeightById(model.Id);

            weight = model.ToEntity(weight);
            _measureService.UpdateMeasureWeight(weight);

            return(Weights(command));
        }
예제 #11
0
        public virtual IActionResult WeightAdd(MeasureWeightModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(AccessDeniedView());
            }

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

            var weight = new MeasureWeight();

            weight = model.ToEntity(weight);
            _measureService.InsertMeasureWeight(weight);

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

            return(Json(new { Result = true }));
        }
예제 #12
0
        public virtual async Task <IActionResult> WeightUpdate(MeasureWeightModel model)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageShippingSettings))
            {
                return(AccessDeniedView());
            }

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

            var weight = await _measureService.GetMeasureWeightByIdAsync(model.Id);

            weight = model.ToEntity(weight);
            await _measureService.UpdateMeasureWeightAsync(weight);

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

            return(new NullJsonResult());
        }
예제 #13
0
        public virtual ActionResult WeightAdd([Bind(Exclude = "Id")] MeasureWeightModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(AccessDeniedView());
            }

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

            var weight = new MeasureWeight();

            weight = model.ToEntity(weight);
            _measureService.InsertMeasureWeight(weight);

            //activity log
            _customerActivityService.InsertActivity("AddNewMeasureWeight", _localizationService.GetResource("ActivityLog.AddNewMeasureWeight"), weight.Id);

            return(new NullJsonResult());
        }