本文整理汇总了C#中Models.Person类的典型用法代码示例。如果您正苦于以下问题:C# Person类的具体用法?C# Person怎么用?C# Person使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Person类属于Models命名空间,在下文中一共展示了Person类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Register_VolunteerAlreadyExists
public void Register_VolunteerAlreadyExists()
{
Person moqPerson = new Person()
{
Id = 1,
UserId = null,
FirstName = "Cathy",
LastName = "Jones",
Email = "[email protected]",
PhoneNumber = "555-222-9139"
};
List<Person> people = new List<Person>();
people.Add(moqPerson);
var moqDataService = new Mock<IDataService>();
moqDataService.Setup(s => s.Persons).Returns(people.AsQueryable());
VolunteerService service = new VolunteerService(moqDataService.Object);
Person actual = service.Register("Cathy", "Jones", "[email protected]", "555-222-9139 ext 33", 6);
Assert.AreEqual("Cathy", actual.FirstName);
Assert.AreEqual("Jones", actual.LastName);
Assert.AreEqual("[email protected]", actual.Email);
Assert.AreEqual("555-222-9139 ext 33", actual.PhoneNumber);
}
示例2: Index
public async Task<ActionResult> Index()
{
var person = new Person
{
Id = "1",
Firstname = "Martijn",
Lastname = "Laarman"
};
_client.Index(person);
_client.IndexMany(new List<Person> { person, person, person });
_client.Get<Person>("1");
_client.DeleteIndex("not-existing-index");
_client.ClusterHealth();
using (MiniProfiler.StepStatic("Async"))
{
await _client.IndexAsync(person);
using (MiniProfiler.StepStatic("Async inner 1"))
{
await _client.IndexAsync(new List<Person> { person, person, person });
}
using (MiniProfiler.StepStatic("Async inner 2"))
{
await _client.IndexManyAsync(new List<Person> { person, person, person });
await _client.GetAsync<Person>("1");
}
}
return View();
}
示例3: Register_ValidVolunteer
public void Register_ValidVolunteer()
{
Person moqPerson = new Person()
{
Id = 1,
UserId = null,
FirstName = "Bob",
LastName = "Jones",
Email = "[email protected]",
PhoneNumber = "555-222-9139",
ClusterId = 1
};
var moqDataService = new Mock<IDataService>();
moqDataService.Setup(s => s.AddPerson(It.IsAny<Person>())).Returns(moqPerson);
VolunteerService service = new VolunteerService(moqDataService.Object);
Person actual = service.Register("Bob", "Jones", "[email protected]", "555-222-9139", 1, 5);
Assert.AreEqual(1, actual.Id);
Assert.AreEqual("Bob", actual.FirstName);
Assert.AreEqual("Jones", actual.LastName);
Assert.AreEqual("[email protected]", actual.Email);
Assert.AreEqual("555-222-9139", actual.PhoneNumber);
Assert.AreEqual(1, actual.ClusterId);
}
示例4: GetPersonDetailsForChangeContactInfoThrowsExpectedPersonNotFoundException
public void GetPersonDetailsForChangeContactInfoThrowsExpectedPersonNotFoundException()
{
var personOne = new Person
{
Id = 1,
UserId = 6,
FirstName = "Cathy",
LastName = "Jones",
Email = "[email protected]",
PhoneNumber = "555-222-9139",
ClusterId = 1
};
var personTwo = new Person
{
Id = 2,
UserId = 7,
FirstName = "Stan",
LastName = "Smith",
Email = "[email protected]",
PhoneNumber = "111-333-2222"
};
var dataService = new Mock<IDataService>();
var personList = new List<Person>
{
personOne,
personTwo
};
dataService.Setup(x => x.Persons).Returns(personList.AsQueryable());
var underTest = new VolunteerService(dataService.Object);
var result = underTest.GetPersonDetailsForChangeContactInfo(8);
}
示例5: About
public ActionResult About()
{
var person = new Person {FirstName = "Rob", LastName = "Gray"};
_personRepository.Save(person);
return View();
}
示例6: Delete
public ActionResult Delete(Person person)
{
if (person != null) {
personList.Remove(person);
}
return RedirectToAction("index");
}
示例7: Create
public ActionResult Create(Person person)
{
if (person != null) {
person.Id = Guid.NewGuid();
personList.Add(person);
}
return RedirectToAction("index");
}
示例8: OnAddExecute
private void OnAddExecute()
{
Log.Info("Adding new person");
var person = new Person();
Persons.Add(person);
SelectedPerson = person;
_flyoutService.ShowFlyout(ExampleEnvironment.PersonFlyoutName, SelectedPerson);
}
示例9: Init
public void Init()
{
_disaster = new Disaster {Id = 0, IsActive = true, Name = "Sharknado"};
_cluster = new Cluster {Id = 1, Name = "Red Zone"};
_person = new Person {Id = 2, FirstName = "John", LastName = "Doe"};
_dataService = new Mock<IDataService>();
_dataService.Setup(x => x.Disasters).Returns(new EnumerableQuery<Disaster>(new[] {_disaster}));
_dataService.Setup(x => x.Clusters).Returns(new EnumerableQuery<Cluster>(new[] {_cluster}));
_dataService.Setup(x => x.Persons).Returns(new EnumerableQuery<Person>(new[] {_person}));
_clusterCoordinatorService = new Services.ClusterCoordinatorService(_dataService.Object);
}
示例10: Index
public ActionResult Index(Person vm)
{
//ModelState.AddModelError(string.Empty, "Class level Error");
//ModelState.AddModelError(string.Empty, "Class level Error 2");
if (ModelState.IsValid)
return Json(new { valid = ModelState.IsValid });
else
{
var errorList = ModelState.ToModelStateJSON();
return Json(new { valid = ModelState.IsValid, validationErrors = errorList });
}
}
示例11: DataToApiModel
public static ApiPerson DataToApiModel(Person person)
{
return new ApiPerson()
{
Id = person.Id,
Username = person.Username,
Email = person.Email,
Password = person.Password,
FirstName = person.FirstName,
LastName = person.LastName,
DOB = person.DOB,
Gender = (ApiGender)person.Gender
};
}
示例12: Init
public void Init()
{
_coordinatorId = 42;
_notCoordinatorId = 10;
_dataService = new Mock<IDataService>();
_disaster1 = new Disaster { Id = 1, IsActive = true, Name = "Sharknado" };
_disaster2 = new Disaster { Id = 2, IsActive = true, Name = "Ice Age" };
_cluster1 = new Cluster { Id = 2, Name = "Red Zone" };
_cluster2 = new Cluster { Id = 3, Name = "Other Cluster" };
_person1 = new Person { Id = 3, FirstName = "John", LastName = "Doe" };
_person2 = new Person { Id = 4, FirstName = "Richard", LastName = "Roe" };
_person3 = new Person { Id = 5, FirstName = "Little", LastName = "Toe" };
_dataService.Setup(x => x.Disasters).Returns(new EnumerableQuery<Disaster>(new[]
{
_disaster1,
_disaster2
}));
_dataService.Setup(x => x.Clusters).Returns(new EnumerableQuery<Cluster>(new[]
{
_cluster1,
_cluster2
}));
_dataService.Setup(x => x.Persons).Returns(new EnumerableQuery<Person>(new[]
{
_person1,
_person2,
_person3
}));
_dataService.Setup(x => x.Commitments).Returns(new EnumerableQuery<Commitment>(new[]
{
new Commitment { DisasterId = _disaster1.Id, PersonId = _person1.Id },
new Commitment { DisasterId = _disaster1.Id, PersonId = _person2.Id },
new Commitment { DisasterId = _disaster2.Id, PersonId = _person3.Id }
}));
_clusterCoordinatorService = new Services.ClusterCoordinatorService(_dataService.Object);
}
示例13: GetPersonDetailsForChangeContactInfoReturnsExpectedData
public void GetPersonDetailsForChangeContactInfoReturnsExpectedData()
{
var personOne = new Person
{
Id = 1,
UserId = 6,
FirstName = "Cathy",
LastName = "Jones",
Email = "[email protected]",
PhoneNumber = "555-222-9139",
ClusterId = 1
};
var personTwo = new Person
{
Id = 2,
UserId = 7,
FirstName = "Stan",
LastName = "Smith",
Email = "[email protected]",
PhoneNumber = "111-333-2222"
};
var dataService = new Mock<IDataService>();
var personList = new List<Person>
{
personOne,
personTwo
};
dataService.Setup(x => x.Persons).Returns(personList.AsQueryable());
var underTest = new VolunteerService(dataService.Object);
var result = underTest.GetPersonDetailsForChangeContactInfo(personTwo.UserId.GetValueOrDefault());
Assert.IsNotNull(result);
Assert.AreEqual(personTwo.Email, result.Email);
Assert.AreEqual(personTwo.PhoneNumber, result.PhoneNumber);
}
示例14: PostPerson
/// <summary>
/// Http : POST
/// </summary>
public async Task PostPerson()
{
await Task.Run(async () =>
{
using (RESTWebClient client = new RESTWebClient())
{
string postUrl = "http://localhost:8001/people";
Person newPerson = new Person();
newPerson.FirstName = string.Format("FirstName_{0}", DateTime.Now.Ticks);
newPerson.LastName = string.Format("LastName_{0}", DateTime.Now.Ticks);
//the server PersonHandler [RouteBaseAttribute] is set to return Xml,
//so we need to deserialize it as Xml
var response = await client.Post<Person>(postUrl, newPerson, SerializationToUse.Xml);
Console.WriteLine("Http : POST");
Console.WriteLine("Status Code : {0}", response.StatusCode);
Console.WriteLine(postUrl);
Console.WriteLine(response.Content);
Console.WriteLine("=================================");
}
});
}
示例15: GetPhisicPersonData
public static DataTable GetPhisicPersonData(int icompany, int iperson, string stypeperson)
{
Person Person = new Person();
return Person.GetPhisicPersonData(icompany, iperson, stypeperson);
}