本文整理汇总了C#中Employee.IsValid方法的典型用法代码示例。如果您正苦于以下问题:C# Employee.IsValid方法的具体用法?C# Employee.IsValid怎么用?C# Employee.IsValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Employee
的用法示例。
在下文中一共展示了Employee.IsValid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: given_employee_with_firstname_when_checking_isvalid_should_be_true
public void given_employee_with_firstname_when_checking_isvalid_should_be_true()
{
var employee = new Employee { FirstName = "Todd" };
employee.IsValid()
.Should()
.BeTrue();
}
示例2: given_employee_without_firstname_when_checking_isvalid_should_be_false
public void given_employee_without_firstname_when_checking_isvalid_should_be_false()
{
var employee = new Employee();
employee.IsValid()
.Should()
.BeFalse();
}
示例3: Create
[AcceptVerbs(HttpVerbs.Post)] // Limits the method to only accept post requests
public ActionResult Create(Employee employee) {
if (ViewData.ModelState.IsValid && employee.IsValid()) {
employeeRepository.SaveOrUpdate(employee);
TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] =
"The employee was successfully created.";
return RedirectToAction("Index");
}
EmployeeFormViewModel viewModel = EmployeeFormViewModel.CreateEmployeeFormViewModel(territoriesRepository);
viewModel.Employee = employee;
return View(viewModel);
}
示例4: Edit
public ActionResult Edit(Employee employee) {
Employee employeeToUpdate = employeeRepository.Get(employee.Id);
TransferFormValuesTo(employeeToUpdate, employee);
if (ViewData.ModelState.IsValid && employee.IsValid()) {
TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] =
"The employee was successfully updated.";
return RedirectToAction("Index");
}
else {
employeeRepository.DbContext.RollbackTransaction();
EmployeeFormViewModel viewModel = EmployeeFormViewModel.CreateEmployeeFormViewModel(territoriesRepository);
viewModel.Employee = employee;
return View(viewModel);
}
}