コード例 #1
0
        public override ActionResult Edit(TEditableModel editableModel, bool continueEditing)
        {
            if (!IsUserizedRequest)
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                InjectModelDependencies(editableModel);

                return(View(editableModel));
            }

            var entity = GetEntityById(editableModel.Id)();

            if (entity == null)
            {
                return(HandleUnknown(editableModel.Id));
            }

            entity = editableModel.ToEntity(entity);

            var operationResult = UpdateEntityAndReturnOperationResult(entity)();

            if (!operationResult.Success)
            {
                ModelState.InjectMessages(operationResult);
                ResourceErrorNotification(CommonConstants.Systematic.NotUpdated);

                InjectModelDependencies(editableModel);

                return(View(editableModel));
            }

            ResourceSuccessNotification(CommonConstants.Systematic.Updated);

            if (continueEditing)
            {
                return(RedirectToAction(KnownActionNames.Edit, RouteParameter.Add(KnownParameterNames.Id, entity.Id)));
            }

            return(RedirectToAction(KnownActionNames.List, RouteParameter.Add(KnownParameterNames.Page, 1)));
        }
コード例 #2
0
        public override ActionResult Edit(long id)
        {
            if (!IsUserizedRequest)
            {
                return(AccessDeniedView());
            }

            var entity = GetEntityById(id)();

            if (entity == null)
            {
                return(HandleUnknown(id));
            }

            var editableModel = entity.ToEditableModel <TEntity, TEditableModel>();

            InjectModelDependencies(editableModel);

            return(View(editableModel));
        }