public virtual IActionResult Create(ContractPeriodModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageContractPeriod))
            {
                return(AccessDeniedView());
            }

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

                //ensure we have "/" at the end


                _contractPeriodService.InsertContractPeriod(item);

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

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

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

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

            //if we got this far, something failed, redisplay form
            return(View(model));
        }
        public virtual IActionResult Edit(ContractPeriodModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageContractPeriod))
            {
                return(AccessDeniedView());
            }

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

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

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


                _contractPeriodService.UpdateContractPeriod(item);

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



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

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

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

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