本文整理汇总了C#中Models.Disaster类的典型用法代码示例。如果您正苦于以下问题:C# Disaster类的具体用法?C# Disaster怎么用?C# Disaster使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Disaster类属于Models命名空间,在下文中一共展示了Disaster类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
});
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}