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


C# Ticket.ValidationResults方法代码示例

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


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

示例1: PublicSubmit

        public ActionResult PublicSubmit(Ticket ticket, string[] avDates, string[] emailCCs, HttpPostedFileBase uploadAttachment, bool captchaValid, string appName, string passedSubject, string availableDatesInput, string emailCCsInput)
        {
            if(!captchaValid)
            {
                ModelState.AddModelError("Captcha", "Captcha values are not valid.");
            }

            if(string.IsNullOrEmpty(ticket.FromEmail) || ticket.FromEmail.Trim() == string.Empty)
            {
                ModelState.AddModelError("Ticket.FromEmail", "Your email address is required.");
            }
            else
            {
                var regExVal = new Regex(StaticValues.EmailErrorRegEx);

                if (!regExVal.IsMatch(ticket.FromEmail.ToLower()))
                {
                    ModelState.AddModelError("Ticket.FromEmail", "A valid email address is required.");
                }
            }

            _ticketControllerService.CommonSubmitValidationChecks(ModelState, ticket, avDates, emailCCs, availableDatesInput, emailCCsInput);

            _ticketControllerService.LoadFileContents(ticket, uploadAttachment);

            MvcValidationAdapter.TransferValidationMessagesTo(ModelState, ticket.ValidationResults());

            if (ModelState.IsValid)
            {
                try
                {
                    //_emailProvider.SendHelpRequest(ticket, true, GetHelpEmail(ticket));
                    _ticketControllerService.SendHelpRequest(ticket, true, _emailProvider);
                    Message = StaticValues.STR_HelpTicketSuccessfullySent;
                    return this.RedirectToAction<HomeController>(a => a.Index(appName, passedSubject));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("Exception", "Application Exception sending email: " + ex.Message);
                    var viewModel = TicketViewModel.Create(Repository.OfType<Application>(), CurrentUser, appName, passedSubject);
                    viewModel.Ticket = ticket;
                    return View(viewModel);
                }
            }
            else
            {
                var viewModel = TicketViewModel.Create(Repository.OfType<Application>(), CurrentUser, appName, passedSubject);
                viewModel.Ticket = ticket;
                return View(viewModel);
            }
        }
开发者ID:ucdavis,项目名称:HelpRequest,代码行数:51,代码来源:TicketController.cs

示例2: Submit

        public ActionResult Submit(Ticket ticket, string[] avDates, string[] emailCCs, HttpPostedFileBase uploadAttachment, string appName, string passedSubject,string availableDatesInput, string emailCCsInput)
        {
            bool foundEmail = false;
            var useKerbEmail = false;
            if (CurrentUser != null && CurrentUser.Identity != null)
            {
                //if (CurrentUser.IsInRole(RoleNames.User) || CurrentUser.IsInRole(RoleNames.Admin))
                //{
                    var user = Repository.OfType<User>()
                        .Queryable
                        .Where(a => a.LoginId == CurrentUser.Identity.Name)
                        .FirstOrDefault();
                    if (user != null)
                    {
                        if (!string.IsNullOrEmpty(user.Email))
                        {
                            foundEmail = true;

                            ticket.User = Repository
                                .OfType<User>()
                                .Queryable
                                .Where(a => a.LoginId == CurrentUser.Identity.Name)
                                .Single();
                        }
                    }
                //}
                if (!foundEmail)
                {
                    var kerbUser = _ticketControllerService.FindKerbUser(CurrentUser.Identity.Name); //DirectoryServices.FindUser(CurrentUser.Identity.Name);
                    if (kerbUser != null)
                    {
                        if (!string.IsNullOrEmpty(kerbUser.EmailAddress))
                        {
                            foundEmail = true;
                            useKerbEmail = true;
                            ticket.FromEmail = kerbUser.EmailAddress;
                        }
                    }
                }
            }
            if (!foundEmail)
            {
                Message = "Logged in email not found. Use this public submit instead.";
                return this.RedirectToAction(a => a.PublicSubmit(appName, passedSubject));
            }

            _ticketControllerService.CommonSubmitValidationChecks(ModelState, ticket, avDates, emailCCs, availableDatesInput, emailCCsInput);
            _ticketControllerService.LoadFileContents(ticket, uploadAttachment);

            MvcValidationAdapter.TransferValidationMessagesTo(ModelState, ticket.ValidationResults());

            if(ModelState.IsValid)
            {
                try
                {
                    //_emailProvider.SendHelpRequest(ticket, useKerbEmail, GetHelpEmail(ticket));
                    _ticketControllerService.SendHelpRequest(ticket, useKerbEmail, _emailProvider);
                    Message = StaticValues.STR_HelpTicketSuccessfullySent;//"Help Ticket successfully sent";
                    return this.RedirectToAction<HomeController>(a => a.Index(appName, passedSubject));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("Exception", "Application Exception sending email: " + ex.Message);
                    //var viewModel = TicketViewModel.Create(Repository, CurrentUser, appName);
                    var viewModel = TicketViewModel.Create(Repository.OfType<Application>(), CurrentUser, appName, passedSubject);
                    viewModel.Ticket = ticket;
                    return View(viewModel);
                }
            }
            else
            {
                //var viewModel = TicketViewModel.Create(Repository, CurrentUser, appName);
                var viewModel = TicketViewModel.Create(Repository.OfType<Application>(), CurrentUser, appName, passedSubject);
                viewModel.Ticket = ticket;
                var test = View(viewModel);

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


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