public void DeleteSubEvent(SubEvent sub_event, ICollection<SubEvent> from = null, bool no_delete = false, bool save = false)
        {
            // 删除与该子活动相关的场地申请
            if (sub_event.LocationApplications != null)
            {
                var locations_applications = sub_event.LocationApplications.ToList();

                foreach (var location_app in locations_applications)
                {
                    db.LocationApplications.Delete(location_app);
                }
            }

            // 删除与该子活动相关的物资申请
            if (sub_event.AssetApplications != null)
            {
                var asset_applications = sub_event.AssetApplications.ToList();

                foreach (var asset_app in asset_applications)
                {
                    db.AssetApplications.Delete(asset_app);
                }
            }

            // 删除该子活动本身
            if (!no_delete)
            {
                if (from == null)
                {
                    db.SubEvents.Delete(sub_event);
                }
                else
                {
                    from.Remove(sub_event);
                }
            }

            if (save)
            {
                db.SaveChanges();
            }
        }
        public void NewLocationApplication(LocationApplication application, SubEvent sub_event, bool no_add = true, bool save = false)
        {
            application.Id = db.GenerateIdFor(IdentityForTPC.APPLICATION);
            application.ApplicantUserName = sub_event.Event.ChiefEventOrganizerId;
            application.ApplicatedDate = sub_event.Date;
            application.ClubId = sub_event.Event.ClubId;
            application.Date = DateTime.Now;
            application.Status = Application.NOT_SUBMITTED;
            application.SubEvent = sub_event;
            application.Times = sub_event.Times;

            ICollection<Location> collection = application.Locations.ToList();
            var locations = db.Locations.ToList().ToList().Where(t => collection.Any(s => s.Id == t.Id));

            application.Locations.Clear();
            foreach (Location location in locations)
            {
                application.Locations.Add(location);
            }

            if (!no_add)
                sub_event.LocationApplications.Add(application);

            if (save)
                db.SaveChanges();
        }
        public void NewAssetApplication(AssetApplication application, SubEvent sub_event, bool no_add = true, bool save = false)
        {
            application.Id = db.GenerateIdFor(IdentityForTPC.APPLICATION);
            application.ApplicantUserName = sub_event.Event.ChiefEventOrganizerId;
            application.ApplicatedDate = sub_event.Date;
            application.ClubId = sub_event.Event.ClubId;
            application.Date = DateTime.Now;
            application.Status = Application.NOT_SUBMITTED;
            application.SubEvent = sub_event;
            application.Times = sub_event.Times;

            foreach (ApplicatedAsset asset in application.ApplicatedAssets)
            {
                asset.Id = db.GenerateIdFor(IdentityForTPC.ASSET_BASE);
                asset.AssetApplicationId = application.Id;
            }

            if (!no_add)
                sub_event.AssetApplications.Add(application);

            if (save)
                db.SaveChanges();
        }