Пример #1
0
        /// <summary>
        /// Prepare return request action model
        /// </summary>
        /// <param name="model">Return request action model</param>
        /// <param name="returnRequestAction">Return request action</param>
        /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param>
        /// <returns>Return request action model</returns>
        public virtual ReturnRequestActionModel PrepareReturnRequestActionModel(ReturnRequestActionModel model,
                                                                                ReturnRequestAction returnRequestAction, bool excludeProperties = false)
        {
            Action <ReturnRequestActionLocalizedModel, int> localizedModelConfiguration = null;

            if (returnRequestAction != null)
            {
                //fill in model values from the entity
                model = model ?? returnRequestAction.ToModel();

                //define localized model configuration action
                localizedModelConfiguration = (locale, languageId) =>
                {
                    locale.Name = returnRequestAction.GetLocalized(entity => entity.Name, languageId, false, false);
                };
            }

            //prepare localized models
            if (!excludeProperties)
            {
                model.Locales = _localizedModelFactory.PrepareLocalizedModels(localizedModelConfiguration);
            }

            return(model);
        }
        /// <returns>A task that represents the asynchronous operation</returns>
        public virtual async Task <IActionResult> ReturnRequestActionCreate(ReturnRequestActionModel model, bool continueEditing)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageSettings))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var returnRequestAction = model.ToEntity <ReturnRequestAction>();
                await _returnRequestService.InsertReturnRequestActionAsync(returnRequestAction);

                //locales
                await UpdateLocalesAsync(returnRequestAction, model);

                _notificationService.SuccessNotification(await _localizationService.GetResourceAsync("Admin.Configuration.Settings.Order.ReturnRequestActions.Added"));

                return(continueEditing
                    ? RedirectToAction("ReturnRequestActionEdit", new { id = returnRequestAction.Id })
                    : RedirectToAction("ReturnRequestActionList"));
            }

            //prepare model
            model = await _returnRequestModelFactory.PrepareReturnRequestActionModelAsync(model, null, true);

            //if we got this far, something failed, redisplay form
            return(View(model));
        }
 /// <returns>A task that represents the asynchronous operation</returns>
 protected virtual async Task UpdateLocalesAsync(ReturnRequestAction rra, ReturnRequestActionModel model)
 {
     foreach (var localized in model.Locales)
     {
         await _localizedEntityService.SaveLocalizedValueAsync(rra,
                                                               x => x.Name,
                                                               localized.Name,
                                                               localized.LanguageId);
     }
 }
Пример #4
0
 protected virtual void UpdateLocales(ReturnRequestAction rra, ReturnRequestActionModel model)
 {
     foreach (var localized in model.Locales)
     {
         _localizedEntityService.SaveLocalizedValue(rra,
                                                    x => x.Name,
                                                    localized.Name,
                                                    localized.LanguageId);
     }
 }
Пример #5
0
        public virtual IActionResult ReturnRequestActionEdit(ReturnRequestActionModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
            {
                return(AccessDeniedView());
            }

            //try to get a return request action with the specified id
            var returnRequestAction = _returnRequestService.GetReturnRequestActionById(model.Id);

            if (returnRequestAction == null)
            {
                return(RedirectToAction("ReturnRequestActionList"));
            }

            if (ModelState.IsValid)
            {
                returnRequestAction = model.ToEntity(returnRequestAction);
                _returnRequestService.UpdateReturnRequestAction(returnRequestAction);

                //locales
                UpdateLocales(returnRequestAction, model);

                _notificationService.SuccessNotification(_localizationService.GetResource("Admin.Configuration.Settings.Order.ReturnRequestActions.Updated"));

                if (!continueEditing)
                {
                    return(RedirectToAction("ReturnRequestActionList"));
                }

                //selected tab
                SaveSelectedTabName();

                return(RedirectToAction("ReturnRequestActionEdit", new { id = returnRequestAction.Id }));
            }

            //prepare model
            model = _returnRequestModelFactory.PrepareReturnRequestActionModel(model, returnRequestAction, true);

            //if we got this far, something failed, redisplay form
            return(View(model));
        }
Пример #6
0
        /// <summary>
        /// Prepare return request action model
        /// </summary>
        /// <param name="model">Return request action model</param>
        /// <param name="returnRequestAction">Return request action</param>
        /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param>
        /// <returns>Return request action model</returns>
        public virtual async Task <ReturnRequestActionModel> PrepareReturnRequestActionModelAsync(ReturnRequestActionModel model,
                                                                                                  ReturnRequestAction returnRequestAction, bool excludeProperties = false)
        {
            Action <ReturnRequestActionLocalizedModel, int> localizedModelConfiguration = null;

            if (returnRequestAction != null)
            {
                //fill in model values from the entity
                model ??= returnRequestAction.ToModel <ReturnRequestActionModel>();

                //define localized model configuration action
                localizedModelConfiguration = async(locale, languageId) =>
                {
                    locale.Name = await _localizationService.GetLocalizedAsync(returnRequestAction, entity => entity.Name, languageId, false, false);
                };
            }

            //prepare localized models
            if (!excludeProperties)
            {
                model.Locales = await _localizedModelFactory.PrepareLocalizedModelsAsync(localizedModelConfiguration);
            }

            return(model);
        }
 public static ReturnRequestAction ToEntity(this ReturnRequestActionModel model, ReturnRequestAction destination)
 {
     return(model.MapTo(destination));
 }
 public static ReturnRequestAction ToEntity(this ReturnRequestActionModel model)
 {
     return(model.MapTo <ReturnRequestActionModel, ReturnRequestAction>());
 }
Пример #9
0
 protected virtual void UpdateLocales(ReturnRequestAction rra, ReturnRequestActionModel model)
 {
     foreach (var localized in model.Locales)
     {
         _localizedEntityService.SaveLocalizedValue(rra,
                                                        x => x.Name,
                                                        localized.Name,
                                                        localized.LanguageId);
     }
 }
Пример #10
0
        public ActionResult ReturnRequestActionEdit(ReturnRequestActionModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
                return AccessDeniedView();

            var rra = _returnRequestService.GetReturnRequestActionById(model.Id);
            if (rra == null)
                //No action found with the specified id
                return RedirectToAction("ReturnRequestActionList");

            if (ModelState.IsValid)
            {
                rra = model.ToEntity(rra);
                _returnRequestService.UpdateReturnRequestAction(rra);
                //locales
                UpdateLocales(rra, model);

                SuccessNotification(_localizationService.GetResource("Admin.Configuration.Settings.Order.ReturnRequestActions.Updated"));
                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabName();

                    return RedirectToAction("ReturnRequestActionEdit", new { id = rra.Id });
                }
                return RedirectToAction("ReturnRequestActionList");
            }

            //If we got this far, something failed, redisplay form
            return View(model);
        }
Пример #11
0
        public ActionResult ReturnRequestActionCreate(ReturnRequestActionModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
                return AccessDeniedView();

            if (ModelState.IsValid)
            {
                var rra = model.ToEntity();
                _returnRequestService.InsertReturnRequestAction(rra);
                //locales
                UpdateLocales(rra, model);

                SuccessNotification(_localizationService.GetResource("Admin.Configuration.Settings.Order.ReturnRequestActions.Added"));
                return continueEditing ? RedirectToAction("ReturnRequestActionEdit", new { id = rra.Id }) : RedirectToAction("ReturnRequestActionList");
            }

            //If we got this far, something failed, redisplay form
            return View(model);
        }
Пример #12
0
        //create
        public ActionResult ReturnRequestActionCreate()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
                return AccessDeniedView();

            var model = new ReturnRequestActionModel();
            //locales
            AddLocales(_languageService, model.Locales);
            return View(model);
        }
Пример #13
0
        protected virtual List<LocalizedProperty> UpdateLocales(ReturnRequestAction rrr, ReturnRequestActionModel model)
        {
            List<LocalizedProperty> localized = new List<LocalizedProperty>();
            foreach (var local in model.Locales)
            {

                localized.Add(new LocalizedProperty()
                {
                    LanguageId = local.LanguageId,
                    LocaleKey = "Name",
                    LocaleValue = local.Name
                });
            }
            return localized;
        }