コード例 #1
0
        public virtual JsonResult ExpireDelegation(string delegationId)
        {
            ResponseBase response;

            int delegationToBeExpiredId = Convert.ToInt32(delegationId);
            var userName     = IDBContext.Current.UserLoginName;
            var errorMessage = delegationToBeExpiredId != 0
                ? SynchronizationHelper.AccessToResources("edit",
                                                          OPUSGlobalValues.URL_DELEGATION,
                                                          delegationId,
                                                          userName)
                : null;

            if (!string.IsNullOrWhiteSpace(errorMessage))
            {
                response = new DelegationSaveResponse
                {
                    IsValid      = false,
                    ErrorMessage = errorMessage
                };
            }
            else
            {
                response = _delegationService.ExpireDelegationNow(delegationToBeExpiredId, -1);

                if (response.IsValid)
                {
                    SynchronizationHelper.TryReleaseLock(OPUSGlobalValues.URL_DELEGATION,
                                                         delegationId.ToString(),
                                                         userName);
                }
            }

            return(Json(response));
        }
コード例 #2
0
        public virtual JsonResult DelegationSave()
        {
            DelegationSaveResponse response;
            var jsonDataRequest = PageSerializationHelper.DeserializeJsonForm(Request.Form[0]);
            var viewModel       = PageSerializationHelper
                                  .DeserializeObject <DelegationViewModel>(jsonDataRequest.SerializedData);

            viewModel.UpdateDelegationViewModel(jsonDataRequest.ClientFieldData);

            viewModel.AssignSubDelegation.Attributes
            .AddRange(_delegationService
                      .GetAttributesEntitiesByOperationType(viewModel.AssignSubDelegation.OperationTypes
                                                            .Where(x => x.OperationTypeSelected)
                                                            .Select(x => x.OperationTypeName).ToList()));

            foreach (var attributeType in viewModel.AssignSubDelegation.Attributes)
            {
                var attributeTypeView =
                    jsonDataRequest.ClientFieldData.FirstOrDefault(o =>
                                                                   !string.IsNullOrWhiteSpace(o.Name) &&
                                                                   o.Name.Equals(attributeType.AttributeControlName));
                if (attributeTypeView != null)
                {
                    attributeType.AttributeSelected = Convert.ToBoolean(attributeTypeView.Value);
                }
            }

            var userName     = IDBContext.Current.UserLoginName;
            var errorMessage = viewModel.DelegationId != 0
                ? SynchronizationHelper.AccessToResources("edit",
                                                          OPUSGlobalValues.URL_DELEGATION,
                                                          viewModel.DelegationId.ToString(),
                                                          userName)
                : null;

            if (!string.IsNullOrWhiteSpace(errorMessage))
            {
                response = new DelegationSaveResponse
                {
                    IsValid      = false,
                    ErrorMessage = errorMessage
                };
            }
            else
            {
                response = _delegationService.DelegatorSearchSave(viewModel);

                if (response.IsValid)
                {
                    SynchronizationHelper.TryReleaseLock(OPUSGlobalValues.URL_DELEGATION,
                                                         viewModel.DelegationId.ToString(),
                                                         userName);
                }
            }

            return(Json(response));
        }