当前位置: 首页>>代码示例>>C#>>正文


C# Editor.TransferValidationMessagesTo方法代码示例

本文整理汇总了C#中Editor.TransferValidationMessagesTo方法的典型用法代码示例。如果您正苦于以下问题:C# Editor.TransferValidationMessagesTo方法的具体用法?C# Editor.TransferValidationMessagesTo怎么用?C# Editor.TransferValidationMessagesTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Editor的用法示例。


在下文中一共展示了Editor.TransferValidationMessagesTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddEditor

        public ActionResult AddEditor(int? templateId, int? callForProposalId, int userId)
        {
            Template template = null;
            CallForProposal callforProposal = null;

            if (!_accessService.HasAccess(templateId, callForProposalId, CurrentUser.Identity.Name))
            {
                Message = string.Format(StaticValues.Message_NoAccess, "that");
                return this.RedirectToAction<HomeController>(a => a.Index());
            }

            if (templateId.HasValue && templateId != 0)
            {
                template = Repository.OfType<Template>().GetNullableById(templateId.Value);
            }
            else if (callForProposalId.HasValue && callForProposalId != 0)
            {
                callforProposal = Repository.OfType<CallForProposal>().GetNullableById(callForProposalId.Value);
            }

            var user = Repository.OfType<User>().GetNullableById(userId);
            if (user == null)
            {
                ModelState.AddModelError("User", "User not found");
                Message = "User not found";
            }

            var editor = new Editor(user, false);
            editor.CallForProposal = callforProposal;
            editor.Template = template;

            editor.TransferValidationMessagesTo(ModelState);

            if (editor.Template != null && _editorRepository.Queryable.Where(a => a.User != null && a.User == editor.User && a.Template != null && a.Template == template).Any())
            {
                ModelState.AddModelError("User", "User already exists");
                Message = "User already exists";
            }

            if (editor.CallForProposal != null && _editorRepository.Queryable.Where(a => a.User != null && a.User == editor.User && a.CallForProposal !=null && a.CallForProposal == callforProposal).Any())
            {
                ModelState.AddModelError("User", "User already exists");
                Message = "User already exists";
            }
            if (ModelState.IsValid)
            {
                Repository.OfType<Editor>().EnsurePersistent(editor);
                Message = "Editor Added";
            }
            else
            {
                Message = string.Format(string.Format("{0} {{0}}", string.Format(StaticValues.Message_UnableToAdd, "editor")), Message);
            }

            return this.RedirectToAction(a => a.Index(templateId, callForProposalId));
        }
开发者ID:ucdavis,项目名称:Gramps,代码行数:56,代码来源:EditorController.cs

示例2: CreateReviewer

        public ActionResult CreateReviewer(int? templateId, int? callForProposalId, Editor editor)
        {
            Template template = null;
            CallForProposal callforProposal = null;

            if (!_accessService.HasAccess(templateId, callForProposalId, CurrentUser.Identity.Name))
            {
                Message = string.Format(StaticValues.Message_NoAccess, "that");
                return this.RedirectToAction<HomeController>(a => a.Index());
            }

            if (templateId.HasValue && templateId != 0)
            {
                template = Repository.OfType<Template>().GetNullableById(templateId.Value);
            }
            else if (callForProposalId.HasValue && callForProposalId !=0)
            {
                callforProposal = Repository.OfType<CallForProposal>().GetNullableById(callForProposalId.Value);
            }

            var editorToCreate = new Editor(editor.ReviewerEmail);

            TransferValues(editor, editorToCreate);
            editorToCreate.Template = template;
            editorToCreate.CallForProposal = callforProposal;

            editorToCreate.TransferValidationMessagesTo(ModelState);

            if (ModelState.IsValid)
            {
                _editorRepository.EnsurePersistent(editorToCreate);

                Message = string.Format(StaticValues.Message_CreatedSuccessfully, "Reviewer"); // "Reviewer Created Successfully";

                return this.RedirectToAction(a => a.Index(templateId, callForProposalId));
            }
            else
            {

                var viewModel = EditorViewModel.Create(Repository, template, callforProposal);
                viewModel.Editor = editorToCreate;

                return View(viewModel);
            }
        }
开发者ID:ucdavis,项目名称:Gramps,代码行数:45,代码来源:EditorController.cs


注:本文中的Editor.TransferValidationMessagesTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。