Example #1
0
        public List <ClubCloud_Lidmaatschap> GetLidmaatschappenForLidmaatschapsoortById(System.Guid Id, bool refresh = false, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            ClubCloud_Lidmaatschapsoort   entity = null;
            List <ClubCloud_Lidmaatschap> result = null;

            using (new SPMonitoredScope("Lidmaatschapsoorten GetLidmaatschappenForLidmaatschapsoortById"))
            {
                try
                {
                    entity = beheerModel.ClubCloud_Lidmaatschapsoorten.Find(Id);
                    if (entity != null && entity.ClubCloud_Lidmaatschap != null && entity.ClubCloud_Lidmaatschap.Count == 0)
                    {
                        beheerModel.Entry(entity).Collection(e => e.ClubCloud_Lidmaatschap).Load();
                    }

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

                    if (result == null || result.Count == 0 || refresh)
                    {
                        result = GetLidmaatschappenForLidmaatschapsoortById(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)
                    {
                        foreach (object item in result)
                        {
                            if (item != null)
                            {
                                try { beheerModel.ObjectContext.Detach(item); } catch {}
                            }
                        }
                    }
                }
            }

            return(new List <ClubCloud_Lidmaatschap>());
        }
Example #2
0
        public bool DeleteLidmaatschapsoort(ClubCloud_Lidmaatschapsoort entity, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            return(DeleteLidmaatschapsoortById(entity.Id, settings));
        }
        public ClubCloud_Lidmaatschapsoort SelectLidmaatschapsoort([QueryString] Guid?Id)  //(string Id)
        {
            ClubCloud_Lidmaatschapsoort entity = null;

            using (new SPMonitoredScope("Lidmaatschapsoorten SelectLidmaatschapsoort"))
            {
                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)
                            {
                            }

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

                            if (entity != null || entity.Id != Guid.Empty)
                            {
                                entity.ClubCloud_Lidmaatschap = new System.Collections.ObjectModel.ObservableCollection <ClubCloud_Lidmaatschap>(Client.GetLidmaatschappenForLidmaatschapsoortById(Id.Value, false, Settings));
                                entity.ClubCloud_Vereniging   = Client.GetVerenigingForLidmaatschapsoortById(Id.Value, false, Settings);
                            }
                        }
                    }
                }
            }

            return(entity);
        }
        public ClubCloud_Lidmaatschapsoort GetLidmaatschapsoortForLidmaatschapById(System.Guid Id, bool refresh = false, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            ClubCloud_Lidmaatschap      entity = null;
            ClubCloud_Lidmaatschapsoort result = null;

            using (new SPMonitoredScope("Lidmaatschappen GetLidmaatschapsoortForLidmaatschapById"))
            {
                try
                {
                    entity = beheerModel.ClubCloud_Lidmaatschappen.Find(Id);
                    if (entity != null && entity.ClubCloud_Lidmaatschapsoort == null)
                    {
                        beheerModel.Entry(entity).Reference(e => e.ClubCloud_Lidmaatschapsoort).Load();
                    }

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

                    if (result == null || refresh)
                    {
                        result = GetLidmaatschapsoortForLidmaatschapById(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_Lidmaatschapsoort());
        }
        public bool SetLidmaatschapsoortForLidmaatschapById(ClubCloud_Lidmaatschapsoort Lidmaatschapsoort, System.Guid Id, bool refresh = false, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            ClubCloud_Lidmaatschap entity = null;
            bool succes = false;

            using (new SPMonitoredScope("Lidmaatschappen SetLidmaatschapsoortForLidmaatschapById"))
            {
                try
                {
                    entity = beheerModel.ClubCloud_Lidmaatschappen.Find(Id);

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

                    if (entity != null)
                    {
                        entity.ClubCloud_Lidmaatschapsoort = Lidmaatschapsoort;
                    }

                    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);
        }
Example #6
0
        public bool SetLidmaatschappenForLidmaatschapsoort(List <ClubCloud_Lidmaatschap> Lidmaatschappen, ClubCloud_Lidmaatschapsoort entity, bool refresh = false, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            bool succes = false;
            ClubCloud_Lidmaatschapsoort result = null;

            using (new SPMonitoredScope("Lidmaatschapsoorten SetLidmaatschappenForLidmaatschapsoort"))
            {
                try
                {
                    entity = beheerModel.ClubCloud_Lidmaatschapsoorten.Find(entity.Id);

                    if (entity != null)
                    {
                        beheerModel.Entry(entity).Collection(e => e.ClubCloud_Lidmaatschap).Load();
                    }
                    //result = GetLidmaatschapsoortById(settings.Id.ToString(), Id, refresh, settings);

                    if (result != null)
                    {
                        //return result.ClubCloud_Lidmaatschapsoorten.Count == ;

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

            return(succes);
        }
        public bool DeleteLidmaatschapsoort(ClubCloud_Lidmaatschapsoort entity)
        {
            using (new SPMonitoredScope("Lidmaatschapsoorten DeleteLidmaatschapsoort"))
            {
                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.DeleteLidmaatschapsoort(entity, Settings));
                    }
                }
            }
            return(false);
        }
Example #8
0
        public ClubCloud_Lidmaatschapsoort SetLidmaatschapsoort(ClubCloud_Lidmaatschapsoort entity, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            ClubCloud_Lidmaatschapsoort tobeupdated = null;

            using (new SPMonitoredScope("Lidmaatschapsoorten SetLidmaatschapsoort"))
            {
                try
                {
                    entity = SetLidmaatschapsoort(settings.Id.ToString(), entity, settings);

                    if (entity != null)
                    {
                        beheerModel.ClubCloud_Lidmaatschapsoorten.AddOrUpdate(entity);
                    }

                    beheerModel.SaveChanges();

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

            return(null);
        }
        public void UpdateLidmaatschapsoort(ClubCloud_Lidmaatschapsoort entity)
        {
            using (new SPMonitoredScope("Lidmaatschapsoorten UpdateLidmaatschapsoort"))
            {
                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)
                    {
                        entity.VerenigingId = Settings.VerenigingId.Value;
                        Client.SetLidmaatschapsoort(entity, Settings);
                        this.OnDataSourceViewChanged(EventArgs.Empty);
                    }
                }
            }
        }
Example #10
0
        public bool DeleteLidmaatschapsoortById(System.Guid Id, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            bool succes = false;
            ClubCloud_Lidmaatschapsoort tobedeleted = null;

            using (new SPMonitoredScope("Lidmaatschapsoorten DeleteLidmaatschapsoortById"))
            {
                try
                {
                    tobedeleted = beheerModel.ClubCloud_Lidmaatschapsoorten.Find(Id);

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

            return(succes);
        }