當前位置: 首頁>>代碼示例>>C#>>正文


C# Models.Disaster類代碼示例

本文整理匯總了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
            });
        }
開發者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


注:本文中的Models.Disaster類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。