本文整理汇总了C#中Models.Disaster类的典型用法代码示例。如果您正苦于以下问题:C# Disaster类的具体用法?C# Disaster怎么用?C# Disaster使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Disaster类属于Models命名空间,在下文中一共展示了Disaster类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: AssignToVolunteer
public Commitment AssignToVolunteer(Disaster disaster, Person person, DateTime startDate, DateTime endDate)
{
if (disaster == null) throw new ArgumentNullException("disaster");
if (person == null) throw new ArgumentNullException("person");
if (DateTime.Compare(endDate, startDate) < 0) throw new ArgumentException("endDate cannot be earlier than startDate");
// check if the start and end date falls within an existing commitment
// disregard any disasters that are inactive
Expression<Func<Commitment, bool>> dateInRange = c =>
(DateTime.Compare(c.StartDate, startDate) <= 0 && DateTime.Compare(c.EndDate, startDate) >= 0) ||
(DateTime.Compare(c.StartDate, endDate) <= 0 && DateTime.Compare(c.EndDate, endDate) >= 0);
var hasExistingCommitment = (from c in ourService.Commitments
join d in ourService.Disasters on c.DisasterId equals d.Id
where d.IsActive
select c).Any(dateInRange);
if (hasExistingCommitment) {
throw new ArgumentException("there is already a commitment for this date range");
}
return ourService.AddCommitment(new Commitment()
{
PersonId = person.Id,
DisasterId = disaster.Id,
StartDate = startDate,
EndDate = endDate
});
}
开发者ID:jmoch01,项目名称:crisischeckin,代码行数:29,代码来源:DisasterService.cs
示例2: Edit
public ActionResult Edit(Disaster disaster)
{
TempData["EditUrlDeprecatedWarning"] = "POST /Edit is deprecated. Use POST /Create instead";
if (ModelState.IsValid && !String.IsNullOrWhiteSpace(disaster.Name))
{
if (disaster.Id == -1)
{
try
{
_disasterSvc.Create(disaster);
}
catch (DisasterAlreadyExistsException)
{
ModelState.AddModelError("Name", "A Disaster already exists with that Name!");
return View("Create", disaster);
}
}
else
{
_disasterSvc.Update(disaster.Id, disaster.Name, disaster.IsActive);
}
return Redirect("/Disaster/List");
}
ModelState.AddModelError("Name", "Disaster Name is required!");
return View("Create", disaster);
}
开发者ID:nguyenlamzx,项目名称:crisischeckin,代码行数:28,代码来源:DisasterController.cs
示例3: Create
public Disaster Create(Disaster disaster)
{
if (disaster == null) throw new ArgumentNullException("disaster");
if (String.IsNullOrWhiteSpace(disaster.Name)) throw new ArgumentNullException("disasterName");
return ourService.AddDisaster(disaster);
}
开发者ID:volkanik,项目名称:crisischeckin,代码行数:7,代码来源:DisasterService.cs
示例4: RetrieveCommitmentsForDisaster
public IQueryable<Commitment> RetrieveCommitmentsForDisaster(Person person, Disaster disaster)
{
if (disaster == null)
throw new ArgumentNullException("disaster", "Disaster cannot be null");
return RetrieveCommitments(person, true).Where(c => c.DisasterId == disaster.Id);
}
开发者ID:jmoch01,项目名称:crisischeckin,代码行数:7,代码来源:VolunteerService.cs
示例5: Edit
public ActionResult Edit(Disaster disaster)
{
if (ModelState.IsValid && !String.IsNullOrWhiteSpace(disaster.Name))
{
if (disaster.Id == -1)
{
try
{
_disasterSvc.Create(disaster);
}
catch (DisasterAlreadyExistsException)
{
ModelState.AddModelError("Name", "A Disaster already exists with that Name!");
return View("Edit", disaster);
}
}
else
{
_disasterSvc.Update(disaster.Id, disaster.Name, disaster.IsActive);
}
return Redirect("/Disaster/List");
}
ModelState.AddModelError("Name", "Disaster Name is required!");
return View(disaster);
}
开发者ID:JaimeLynSchatz,项目名称:crisischeckin,代码行数:27,代码来源:DisasterController.cs
示例6: GetDisasterClusterCoordinatorsViewModel
DisasterClusterCoordinatorsViewModel GetDisasterClusterCoordinatorsViewModel(Disaster disaster)
{
IList<Person> allPersonDataForDisplay;
var clusterCoordinators = _clusterCoordinatorService.GetAllCoordinatorsForDisplay(disaster.Id, out allPersonDataForDisplay);
var allClusters = _cluster.GetList().ToList();
var disasterClusterCoordinatorsViewModel =
new DisasterClusterCoordinatorsViewModel
{
DisasterName = disaster.Name,
DisasterId = disaster.Id,
Clusters = allClusters
.Select(c => new ClusterViewModel
{
Name = c.Name,
Coordinators = clusterCoordinators
.Where(x => x.ClusterId == c.Id)
.Select(x => new ClusterCoordinatorViewModel
{
Name = x.Person.FullName,
Id = x.Id,
})
.ToList(),
})
.ToList(),
AvailableClusters = allClusters,
AvailablePeople = allPersonDataForDisplay
};
return disasterClusterCoordinatorsViewModel;
}
开发者ID:dayewah,项目名称:crisischeckin,代码行数:29,代码来源:ClusterCoordinatorController.cs
示例7: GetVolunteersForDate
public IEnumerable<Person> GetVolunteersForDate(Disaster disaster, DateTime date)
{
if (disaster == null)
throw new ArgumentNullException("disaster", "disaster cannot be null");
return GetVolunteersForDate(disaster.Id, date);
}
开发者ID:vkarosas,项目名称:crisischeckin,代码行数:7,代码来源:AdminService.cs
示例8: Create
public ActionResult Create(DisasterViewModel model)
{
if (ModelState.IsValid)
{
try
{
var disaster = new Disaster
{
Id = model.Id,
Name = model.Name,
IsActive = model.IsActive
};
if (model.Id == -1)
{
_disasterSvc.Create(disaster);
}
else
{
_disasterSvc.Update(disaster);
}
}
catch (DisasterAlreadyExistsException)
{
ModelState.AddModelError("Name", "A Disaster already exists with that Name!");
return View("Create", model);
}
return Redirect("/Disaster/List");
}
return View("Create", model);
}
开发者ID:ImadBouirmane,项目名称:crisischeckin,代码行数:32,代码来源:DisasterController.cs
示例9: GetVolunteersForDate
public IEnumerable<Person> GetVolunteersForDate(Disaster disaster, DateTime date, bool clusterCoordinatorsOnly, bool checkedInOnly = false)
{
if (disaster == null)
throw new ArgumentNullException("disaster", "disaster cannot be null");
return GetVolunteersForDate(disaster.Id, date, clusterCoordinatorsOnly, checkedInOnly);
}
开发者ID:mjmilan,项目名称:crisischeckin,代码行数:7,代码来源:AdminService.cs
示例10: Create
public Disaster Create(Disaster disaster)
{
if (disaster == null) throw new ArgumentNullException("disaster");
if (String.IsNullOrWhiteSpace(disaster.Name)) throw new ArgumentNullException("disasterName");
if (ourService.Disasters.Any(d => d.Name == disaster.Name)) throw new DisasterAlreadyExistsException();
return ourService.AddDisaster(disaster);
}
开发者ID:jmoch01,项目名称:crisischeckin,代码行数:8,代码来源:DisasterService.cs
示例11: GetPeople
private IQueryable<Person> GetPeople(Disaster disaster)
{
var people = from p in dataService.Persons
join c in dataService.Commitments on p.Id equals c.PersonId
where c.DisasterId == disaster.Id
select p;
return people;
}
开发者ID:nguyenlamzx,项目名称:crisischeckin,代码行数:9,代码来源:AdminService.cs
示例12: Create
public void Create(Disaster disaster)
{
if (disaster == null) throw new ArgumentNullException("disaster");
if (String.IsNullOrWhiteSpace(disaster.Name)) throw new ArgumentNullException("disaster");
if (_dataService.Disasters.Any(d => d.Name == disaster.Name)) throw new DisasterAlreadyExistsException();
// Why should disaster name be unique?
_dataService.AddDisaster(disaster);
}
开发者ID:JaimeLynSchatz,项目名称:crisischeckin,代码行数:9,代码来源:DisasterService.cs
示例13: Create_a_disaster
void Create_a_disaster()
{
_disaster = new Disaster
{
IsActive = true,
Name = "Great Seattle Starbucks Strike",
};
_dataService.AddDisaster(_disaster);
_clusterId = _dataService.Clusters.First().Id;
}
开发者ID:nterry,项目名称:crisischeckin,代码行数:10,代码来源:A_person_can_be_assigned_as_a_cluster_coordinator_for_a_disaster.cs
示例14: Create_a_disaster
public Disaster Create_a_disaster()
{
var disaster = new Disaster
{
IsActive = true,
Name = "Great Seattle Starbucks Strike",
};
_dataService.AddDisaster(disaster);
return disaster;
}
开发者ID:ImadBouirmane,项目名称:crisischeckin,代码行数:10,代码来源:DataAccessHelper.cs
示例15: GetVolunteers
public IEnumerable<Person> GetVolunteers(Disaster disaster)
{
if (disaster == null)
throw new ArgumentNullException("disaster", "disaster cannot be null");
var storedDisaster = dataService.Disasters.SingleOrDefault(d => d.Id == disaster.Id);
if (storedDisaster == null)
throw new ArgumentException("Disaster was not found", "disaster");
IQueryable<Person> people = GetPeople(disaster);
return people;
}
开发者ID:CRSnyder,项目名称:crisischeckin,代码行数:10,代码来源:AdminService.cs
示例16: GetVolunteers
public IEnumerable<Person> GetVolunteers(Disaster disaster, bool checkedInOnly = false)
{
if (disaster == null)
throw new ArgumentNullException("disaster", "disaster cannot be null");
var people = GetPeople(disaster.Id, checkedInOnly);
if (people == null)
throw new NullReferenceException(string.Format("Attempt to get volunteers for disaster ID {0} returned null.", disaster.Id));
return people.ToList();
}
开发者ID:mjmilan,项目名称:crisischeckin,代码行数:11,代码来源:AdminService.cs
示例17: 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);
}
开发者ID:dayewah,项目名称:crisischeckin,代码行数:13,代码来源:AssignClusterCoordinatorTests.cs
示例18: AssignToVolunteer
public Commitment AssignToVolunteer(Disaster disaster, Person person, DateTime startDate, DateTime endDate)
{
if (disaster == null) throw new ArgumentNullException("disaster");
if (person == null) throw new ArgumentNullException("person");
if (DateTime.Compare(endDate, startDate) < 0) throw new ArgumentException("endDate cannot be earlier than startDate");
return ourService.AddCommitment(new Commitment()
{
PersonId = person.Id,
DisasterId = disaster.Id,
StartDate = startDate,
EndDate = endDate
});
}
开发者ID:volkanik,项目名称:crisischeckin,代码行数:14,代码来源:DisasterService.cs
示例19: Assign_ValidDataAdd_ReturnsListView
public void Assign_ValidDataAdd_ReturnsListView()
{
// Arrange
var disaster = new Mock<IDisaster>();
var controller = new DisasterController(disaster.Object);
// Act
var viewModel = new Disaster { Id = -1, Name ="test", IsActive = false};
var response = controller.Create(viewModel);
// Assert
var result = response as RedirectResult;
Assert.IsTrue(result.Url.Equals("/Disaster/List"));
}
开发者ID:vkarosas,项目名称:crisischeckin,代码行数:15,代码来源:DisasterControllerTests.cs
示例20: Lookup_UnfilteredVolunteers_For_Disaster_Returns_AllVolunteers_ForTheDisaster
public void Lookup_UnfilteredVolunteers_For_Disaster_Returns_AllVolunteers_ForTheDisaster()
{
//Arrange
int disasterId = 2;
var disaster = new Disaster();
_disasterSvc.Setup(x => x.Get(disasterId)).Returns(disaster);
var allVolunteers = new Collection<Person>();
_adminSvc.Setup(x => x.GetVolunteers(disaster)).Returns(allVolunteers);
var controller = CreateVolunteerController();
//Act
var response = controller.Filter(new ListByDisasterViewModel() { SelectedDisaster = disasterId, CommitmentDate = null });
//Assert
Assert.AreEqual(allVolunteers, response.Model);
}
开发者ID:TomDeVree,项目名称:crisischeckin,代码行数:17,代码来源:VolunteerControllerTests.cs
注:本文中的Models.Disaster类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论