コード例 #1
0
        public virtual IActionResult Create(ContractTypeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageContractType))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var item = model.ToEntity <ContractType>();

                //ensure we have "/" at the end


                _contractTypeService.InsertContractType(item);

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

                SuccessNotification(_localizationService.GetResource("AppWork.Contracts.ContractType.Added"));

                return(continueEditing ? RedirectToAction("Edit", new { id = item.Id }) : RedirectToAction("List"));
            }

            //prepare model
            model = _contractModelFactory.PrepareContractTypeModel(model, null);

            //if we got this far, something failed, redisplay form
            return(View(model));
        }
コード例 #2
0
        public virtual IActionResult _Create(ContractTypeModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageContractType))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var item = model.ToEntity <ContractType>();

                //ensure we have "/" at the end


                _contractTypeService.InsertContractType(item);

                //activity log
                _customerActivityService.InsertActivity("AddNewContractType",
                                                        string.Format(_localizationService.GetResource("ActivityLog.AddNewContractType"), item.Id), item);
                return(JsonSuccessMessage(_localizationService.GetResource("AppWork.Contracts.ContractType.Added"), item.ToModel <ContractTypeModel>()));
            }

            //prepare model
            model = _contractModelFactory.PrepareContractTypeModel(model, null);

            //if we got this far, something failed, redisplay form
            return(JsonErrorMessage(_localizationService.GetResource("AppWork.Contracts.Contract.AddNewContractTypeError"), model));
        }
コード例 #3
0
        public virtual IActionResult Edit(ContractTypeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageContractType))
            {
                return(AccessDeniedView());
            }

            //try to get a store with the specified id
            var item = _contractTypeService.GetContractTypeById(model.Id);

            if (item == null)
            {
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                item = model.ToEntity(item);


                _contractTypeService.UpdateContractType(item);

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



                SuccessNotification(_localizationService.GetResource("AppWork.Contracts.ContractType.Updated"));

                return(continueEditing ? RedirectToAction("Edit", new { id = item.Id }) : RedirectToAction("List"));
            }

            //prepare model
            model = _contractModelFactory.PrepareContractTypeModel(model, item, true);

            //if we got this far, something failed, redisplay form
            return(View(model));
        }