本文整理汇总了C#中Application.TransferValidationMessagesTo方法的典型用法代码示例。如果您正苦于以下问题:C# Application.TransferValidationMessagesTo方法的具体用法?C# Application.TransferValidationMessagesTo怎么用?C# Application.TransferValidationMessagesTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Application
的用法示例。
在下文中一共展示了Application.TransferValidationMessagesTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
public ActionResult Apply(Application application, HttpPostedFileBase file, bool seminarTerms)
{
ModelState.Clear();
application.Seminar = SiteService.GetLatestSeminar(Site, true);
application.User = Repository.OfType<User>().Queryable.FirstOrDefault(a => a.LoweredUserName == CurrentUser.Identity.Name.ToLower());
// requires assistant
if (application.CommunicationOption == null)
{
ModelState.AddModelError("Communication Option", "No communication option was selected.");
}
else
{
if (application.CommunicationOption.RequiresAssistant)
{
if (string.IsNullOrWhiteSpace(application.FirstName) && string.IsNullOrWhiteSpace(application.LastName))
{
ModelState.AddModelError("Assistant Name", "Because of your communication preference an Assistant Name is required.");
}
if (string.IsNullOrWhiteSpace(application.AssistantPhone))
{
ModelState.AddModelError("Assistant Name", "Because of your communication preference an Assistant Phone is required.");
}
if (string.IsNullOrWhiteSpace(application.AssistantEmail))
{
ModelState.AddModelError("Assistant Name", "Because of your communication preference an Assistant Email is required.");
}
}
}
if (file != null)
{
// read the file
var reader = new BinaryReader(file.InputStream);
application.Photo = reader.ReadBytes(file.ContentLength);
application.ContentType = file.ContentType;
}
if (application.Firm != null && application.Firm.Id == 0)
{
application.Firm = null;
}
application.TransferValidationMessagesTo(ModelState);
//var test = application.Firm;
//ModelState.AddModelError("Firm", "Please define a firm");
if (application.FirmType != null && application.FirmType.Name == "Other" && string.IsNullOrWhiteSpace(application.OtherFirmType))
{
ModelState.AddModelError("Firm Type", "Please define Firm Type.");
}
if (!seminarTerms) ModelState.AddModelError("Seminar Terms", "Agreeing to the seminar terms are required.");
if (ModelState.IsValid)
{
_applicationRepository.EnsurePersistent(application);
_eventService.Apply(application.User.Person, application, Site);
if (application.Seminar.RequireApproval)
{
if (application.Seminar.AcceptanceDate.HasValue)
{
Message = string.Format("Thank you for successfully submitting your application.<br/> Applicants will be notified of acceptance by {0}", application.Seminar.AcceptanceDate.Value.ToString("d"));
}
else
{
Message = "Thank you for successfully submitting your application.<br/> Applicants will be notified in the near future.";
}
}
else
{
application.IsPending = false;
application.IsApproved = true;
application.DateDecision = DateTime.Now;
application.DecisionReason = "Approval not required.";
var person = _personService.CreateSeminarPerson(application, ModelState);
_applicationRepository.EnsurePersistent(application);
_eventService.Accepted(person, Site);
}
if (application.Photo != null)
{
return this.RedirectToAction("UpdateProfilePicture", "Person", new {id = application.User.Person.Id});
}
return this.RedirectToAction<AuthorizedController>(a => a.Index());
}
var viewModel = ApplicationViewModel.Create(Repository, _firmService, CurrentUser.Identity.Name, Site, application, seminarTerms);
return View(viewModel);
}