Ejemplo n.º 1
0
        public virtual IActionResult Create(CreateMaterialGroupModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(XrmsPermissionProvider.ManageMaterialGroups))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var group = model.ToEntity();
                group.CreatedOnUtc = DateTime.UtcNow;
                group.UpdatedOnUtc = DateTime.UtcNow;
                _materialGroupService.InsertMaterialGroup(group);

                //activity log
                _customerActivityService.InsertActivity("AddNewMaterialGroup", _localizationService.GetResource("Xrms.ActivityLog.AddNewMaterialGroup"), group);

                SuccessNotification(_localizationService.GetResource("Xrms.Admin.Catalog.MaterialGroups.Notifications.Created"));

                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabName();

                    return(RedirectToAction("Edit", new { id = group.Id }));
                }
                return(RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            var viewModel = new MaterialGroupDetailsPageViewModel();

            model.ToDetailsViewModel(viewModel);
            //viewModel.MaterialGroupInfo = model;

            // prepare parent groups
            PrepareAvailableMaterialGroups(viewModel);

            return(View("~/Plugins/Xrms/Areas/Admin/Views/MaterialGroup/Create.cshtml", viewModel));
        }
Ejemplo n.º 2
0
 public static MaterialGroup ToEntity(this CreateMaterialGroupModel model, MaterialGroup entity)
 {
     return(model.MapTo(entity));
 }
Ejemplo n.º 3
0
 public static MaterialGroupDetailsPageViewModel ToDetailsViewModel(this CreateMaterialGroupModel model, MaterialGroupDetailsPageViewModel viewModel)
 {
     return(model.MapTo(viewModel));
 }
Ejemplo n.º 4
0
 // from action model to entity
 public static MaterialGroup ToEntity(this CreateMaterialGroupModel model)
 {
     return(model.MapTo <CreateMaterialGroupModel, MaterialGroup>());
 }