public virtual IActionResult Create(CreateMaterialModel model, bool continueEditing) { if (!_permissionService.Authorize(XrmsPermissionProvider.ManageMaterials)) { return(AccessDeniedView()); } if (ModelState.IsValid) { //a vendor should have access only to his materials /*if (_workContext.CurrentVendor != null) * { * model.VendorId = _workContext.CurrentVendor.Id; * }*/ //material var material = model.ToEntity(); material.CreatedOnUtc = DateTime.UtcNow; material.UpdatedOnUtc = DateTime.UtcNow; _materialService.InsertMaterial(material); // quantity change history _materialService.AddStockQuantityHistoryEntry(material, material.StockQuantity, material.StockQuantity, material.WarehouseId, _localizationService.GetResource("Xrms.Admin.Catalog.Materials.StockQuantityHistory.Messages.Edit")); // activity log _customerActivityService.InsertActivity("AddNewMaterial", _localizationService.GetResource("Xrms.ActivityLog.AddNewMaterial"), material); SuccessNotification(_localizationService.GetResource("Xrms.Admin.Catalog.Materials.Notifications.Added")); if (continueEditing) { //selected tab SaveSelectedTabName(); return(RedirectToAction("Edit", new { id = material.Id })); } return(RedirectToAction("List")); } //If we got this far, something failed, redisplay form var viewModel = new MaterialDetailsPageViewModel(); model.ToDetailsViewModel(viewModel); //viewModel.MaterialGroupInfo = model; // groups PrepareAvailableMaterialGroups(viewModel); // warehouses PrepareAvailableWarehouses(viewModel); return(View("~/Plugins/Xrms/Areas/Admin/Views/Material/Create.cshtml", viewModel)); }