示例#1
0
        public ClubCloud_Accommodatie GetAccommodatieForAddressById(System.Guid Id, bool refresh = false, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            ClubCloud_Address      entity = null;
            ClubCloud_Accommodatie result = null;

            using (new SPMonitoredScope("Addressen GetAccommodatieForAddressById"))
            {
                try
                {
                    entity = beheerModel.ClubCloud_Addressen.Find(Id);
                    if (entity != null && entity.ClubCloud_Accommodatie == null)
                    {
                        beheerModel.Entry(entity).Reference(e => e.ClubCloud_Accommodatie).Load();
                    }

                    if (entity != null)
                    {
                        result = entity.ClubCloud_Accommodatie;
                    }

                    if (result == null || refresh)
                    {
                        result = GetAccommodatieForAddressById(settings.Id.ToString(), Id, refresh, settings);
                    }

                    if (result != null)
                    {
                        return(result);
                    }
                }
                catch (Exception ex)
                {
                    Logger.WriteLog(Logger.Category.Unexpected, ex.Source, ex.Message);
                }
                finally
                {
                    if (entity != null)
                    {
                        try { beheerModel.ObjectContext.Detach(entity); } catch {}
                    }
                    if (result != null)
                    {
                        try { beheerModel.ObjectContext.Detach(result); } catch {}
                    }
                }
            }

            return(new ClubCloud_Accommodatie());
        }
示例#2
0
        public bool SetAccommodatieForAddressById(ClubCloud_Accommodatie Accommodatie, System.Guid Id, bool refresh = false, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            ClubCloud_Address entity = null;
            bool succes = false;

            using (new SPMonitoredScope("Addressen SetAccommodatieForAddressById"))
            {
                try
                {
                    entity = beheerModel.ClubCloud_Addressen.Find(Id);

                    if (entity != null && entity.ClubCloud_Accommodatie == null)
                    {
                        beheerModel.Entry(entity).Reference(e => e.ClubCloud_Accommodatie).Load();
                    }

                    if (entity != null)
                    {
                        entity.ClubCloud_Accommodatie = Accommodatie;
                    }

                    beheerModel.SaveChanges();
                    succes = true;
                }
                catch (Exception ex)
                {
                    Logger.WriteLog(Logger.Category.Unexpected, ex.Source, ex.Message);
                }
                finally
                {
                    if (entity != null)
                    {
                        try { beheerModel.ObjectContext.Detach(entity); } catch {}
                    }
                }
            }

            return(succes);
        }
示例#3
0
        public void UpdateAccommodatie(ClubCloud_Accommodatie entity)
        {
            using (new SPMonitoredScope("Accommodaties UpdateAccommodatie"))
            {
                if (SPContext.Current.Web.CurrentUser != null)
                {
                    int bondsnummer;
                    ClubCloud_Setting Settings = null;
                    if (int.TryParse(SPContext.Current.Web.CurrentUser.UserId.NameId, out bondsnummer))
                    {
                        Settings = Client.GetSettingById(bondsnummer);
                    }

                    if (Settings != null && Settings.VerenigingId != null)
                    {
                        Client.SetAccommodatie(entity, Settings);
                        this.OnDataSourceViewChanged(EventArgs.Empty);
                    }
                }
            }
        }
示例#4
0
        public bool DeleteAccommodatie(ClubCloud_Accommodatie entity)
        {
            using (new SPMonitoredScope("Accommodaties DeleteAccommodatie"))
            {
                if (SPContext.Current.Web.CurrentUser != null)
                {
                    int bondsnummer;
                    ClubCloud_Setting Settings = null;
                    if (int.TryParse(SPContext.Current.Web.CurrentUser.UserId.NameId, out bondsnummer))
                    {
                        Settings = Client.GetSettingById(bondsnummer);
                    }

                    if (Settings != null && Settings.VerenigingId != null)
                    {
                        return(Client.DeleteAccommodatie(entity, Settings));
                    }
                }
            }
            return(false);
        }
示例#5
0
        public ClubCloud_Accommodatie SelectAccommodatie([QueryString] Guid?Id)  //(string Id)
        {
            ClubCloud_Accommodatie entity = null;

            using (new SPMonitoredScope("Accommodaties SelectAccommodatie"))
            {
                if (SPContext.Current.Web.CurrentUser != null)
                {
                    int bondsnummer;
                    ClubCloud_Setting Settings = null;
                    if (int.TryParse(SPContext.Current.Web.CurrentUser.UserId.NameId, out bondsnummer))
                    {
                        Settings = Client.GetSettingById(bondsnummer);
                    }

                    if (Settings != null && Settings.VerenigingId != null)
                    {
                        Settings.ClubCloud_Vereniging = Client.GetVerenigingById(Settings.VerenigingId.Value, false, Settings);

                        if (Settings.ClubCloud_Vereniging != null)
                        {
                            if (Id == null)
                            {
                                Guid queryId = Guid.Empty;
                                foreach (Parameter where in WhereParameters)
                                {
                                    if (where.Name == "Id")
                                    {
                                        if (Guid.TryParse(where.DefaultValue, out queryId))
                                        {
                                            break;
                                        }
                                    }
                                }

                                Id = queryId;
                            }

                            if (Id == Guid.Empty)
                            {
                                Settings.ClubCloud_Vereniging = Client.GetVerenigingById(Settings.VerenigingId.Value, false, Settings);
                                Id = Settings.ClubCloud_Vereniging.AccommodatieId.Value;
                            }

                            entity = Client.GetAccommodatieById(Id.Value, false, Settings);

                            if (entity != null || entity.Id != Guid.Empty)
                            {
                                entity.ClubCloud_District     = Client.GetDistrictForAccommodatieById(Id.Value, false, Settings);
                                entity.ClubCloud_Regio        = Client.GetRegioForAccommodatieById(Id.Value, false, Settings);
                                entity.ClubCloud_Baanblok     = new System.Collections.ObjectModel.ObservableCollection <ClubCloud_Baanblok>(Client.GetBaanblokkenForAccommodatieById(Id.Value, false, Settings));
                                entity.ClubCloud_Baan         = new System.Collections.ObjectModel.ObservableCollection <ClubCloud_Baan>(Client.GetBanenForAccommodatieById(Id.Value, false, Settings));
                                entity.ClubCloud_BaanSpeciaal = new System.Collections.ObjectModel.ObservableCollection <ClubCloud_BaanSpeciaal>(Client.GetBanenSpeciaalForAccommodatieById(Id.Value, false, Settings));
                                entity.ClubCloud_Address      = new System.Collections.ObjectModel.ObservableCollection <ClubCloud_Address>(Client.GetAddressenForAccommodatieById(Id.Value, false, Settings));
                            }
                        }
                    }
                }
            }

            return(entity);
        }