Exemplo n.º 1
0
        public bool DeleteBaanschema(ClubCloud_Baanschema entity, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            return(DeleteBaanschemaById(entity.Id, settings));
        }
        public ClubCloud_Baanschema SelectBaanschema([QueryString] Guid?Id)  //(string Id)
        {
            ClubCloud_Baanschema entity = null;

            using (new SPMonitoredScope("Baanschemas SelectBaanschema"))
            {
                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.GetBaanschemaById(Id.Value, false, Settings);

                            if (entity != null || entity.Id != Guid.Empty)
                            {
                                entity.ClubCloud_Baan       = Client.GetBaanForBaanschemaById(Id.Value, false, Settings);
                                entity.ClubCloud_Vereniging = Client.GetVerenigingForBaanschemaById(Id.Value, false, Settings);
                            }
                        }
                    }
                }
            }

            return(entity);
        }
Exemplo n.º 3
0
        public ClubCloud_Vereniging GetVerenigingForBaanschemaById(System.Guid Id, bool refresh = false, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            ClubCloud_Baanschema entity = null;
            ClubCloud_Vereniging result = null;

            using (new SPMonitoredScope("Baanschemas GetVerenigingForBaanschemaById"))
            {
                try
                {
                    entity = beheerModel.ClubCloud_Baanschemas.Find(Id);
                    if (entity != null && entity.ClubCloud_Vereniging == null)
                    {
                        beheerModel.Entry(entity).Reference(e => e.ClubCloud_Vereniging).Load();
                    }

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

                    if (result == null || refresh)
                    {
                        result = GetVerenigingForBaanschemaById(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_Vereniging());
        }
Exemplo n.º 4
0
        public bool SetVerenigingForBaanschemaById(ClubCloud_Vereniging Vereniging, System.Guid Id, bool refresh = false, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            ClubCloud_Baanschema entity = null;
            bool succes = false;

            using (new SPMonitoredScope("Baanschemas SetVerenigingForBaanschemaById"))
            {
                try
                {
                    entity = beheerModel.ClubCloud_Baanschemas.Find(Id);

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

                    if (entity != null)
                    {
                        entity.ClubCloud_Vereniging = Vereniging;
                    }

                    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);
        }
        public bool DeleteBaanschema(ClubCloud_Baanschema entity)
        {
            using (new SPMonitoredScope("Baanschemas DeleteBaanschema"))
            {
                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.DeleteBaanschema(entity, Settings));
                    }
                }
            }
            return(false);
        }
Exemplo n.º 6
0
        public ClubCloud_Baanschema GetBaanschemaById(System.Guid Id, bool refresh = false, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            ClubCloud_Baanschema result = null;

            using (new SPMonitoredScope("Baanschemas GetBaanschemaById"))
            {
                try
                {
                    result = beheerModel.ClubCloud_Baanschemas.Find(Id);

                    if (result == null || refresh)
                    {
                        result = GetBaanschemaById(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 (result != null)
                    {
                        try { beheerModel.ObjectContext.Detach(result); } catch {}
                    }
                }
            }

            return(new ClubCloud_Baanschema());
        }
Exemplo n.º 7
0
        public ClubCloud_Baanschema SetBaanschema(ClubCloud_Baanschema entity, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            ClubCloud_Baanschema tobeupdated = null;

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

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

                    beheerModel.SaveChanges();

                    tobeupdated = beheerModel.ClubCloud_Baanschemas.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 UpdateBaanschema(ClubCloud_Baanschema entity)
        {
            using (new SPMonitoredScope("Baanschemas UpdateBaanschema"))
            {
                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.SetBaanschema(entity, Settings);
                        this.OnDataSourceViewChanged(EventArgs.Empty);
                    }
                }
            }
        }
Exemplo n.º 9
0
        public bool DeleteBaanschemaById(System.Guid Id, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            bool succes = false;
            ClubCloud_Baanschema tobedeleted = null;

            using (new SPMonitoredScope("Baanschemas DeleteBaanschemaById"))
            {
                try
                {
                    tobedeleted = beheerModel.ClubCloud_Baanschemas.Find(Id);

                    if (tobedeleted != null)
                    {
                        beheerModel.ClubCloud_Baanschemas.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);
        }