Ejemplo n.º 1
0
        public List <ClubCloud_Baanblok> GetBaanblokkenForBaansoortById(System.Guid Id, bool refresh = false, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            ClubCloud_Baansoort       entity = null;
            List <ClubCloud_Baanblok> result = null;

            using (new SPMonitoredScope("Baansoorten GetBaanblokkenForBaansoortById"))
            {
                try
                {
                    entity = beheerModel.ClubCloud_Baansoorten.Find(Id);
                    if (entity != null && entity.ClubCloud_Baanblok != null && entity.ClubCloud_Baanblok.Count == 0)
                    {
                        beheerModel.Entry(entity).Collection(e => e.ClubCloud_Baanblok).Load();
                    }

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

                    if (result == null || result.Count == 0 || refresh)
                    {
                        result = GetBaanblokkenForBaansoortById(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_Baanblok>());
        }
Ejemplo n.º 2
0
        public bool DeleteBaansoort(ClubCloud_Baansoort entity, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            return(DeleteBaansoortById(entity.Id, settings));
        }
        public ClubCloud_Baansoort SelectBaansoort([QueryString] Guid?Id)  //(string Id)
        {
            ClubCloud_Baansoort entity = null;

            using (new SPMonitoredScope("Baansoorten SelectBaansoort"))
            {
                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.GetBaansoortById(Id.Value, false, Settings);

                            if (entity != null || entity.Id != Guid.Empty)
                            {
                                entity.ClubCloud_Baantype = Client.GetBaantypeForBaansoortById(Id.Value, false, Settings);
                                entity.ClubCloud_Baanblok = new System.Collections.ObjectModel.ObservableCollection <ClubCloud_Baanblok>(Client.GetBaanblokkenForBaansoortById(Id.Value, false, Settings));
                            }
                        }
                    }
                }
            }

            return(entity);
        }
Ejemplo n.º 4
0
        public ClubCloud_Baantype GetBaantypeForBaansoortById(System.Guid Id, bool refresh = false, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            ClubCloud_Baansoort entity = null;
            ClubCloud_Baantype  result = null;

            using (new SPMonitoredScope("Baansoorten GetBaantypeForBaansoortById"))
            {
                try
                {
                    entity = beheerModel.ClubCloud_Baansoorten.Find(Id);
                    if (entity != null && entity.ClubCloud_Baantype == null)
                    {
                        beheerModel.Entry(entity).Reference(e => e.ClubCloud_Baantype).Load();
                    }

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

                    if (result == null || refresh)
                    {
                        result = GetBaantypeForBaansoortById(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_Baantype());
        }
Ejemplo n.º 5
0
        public async Task <Models.Baansoort> GetBaansoortAsync(Guid verenigingId, Guid accommodatieId, Guid baansoortId)
        {
            Models.Baansoort _baansoort = new Models.Baansoort();

            ClubCloud_Baansoort baansoort = await client.GetBaansoortByIdAsync("0000000", verenigingId, accommodatieId, baansoortId, false);

            _baansoort = new Models.Baansoort {
                Id = baansoort.Id, Naam = baansoort.Naam, Beschrijving = baansoort.Beschrijving, BaantypeId = baansoort.BaantypeId.Value, Code = baansoort.Code, Meervoud = baansoort.Meervoud, Omschrijving = baansoort.Omschrijving
            };

            return(_baansoort);
        }
Ejemplo n.º 6
0
        public ClubCloud_Baansoort GetBaansoortById(string bondsnummer, Guid verenigingId, Guid accommodatieId, Guid baansoortId, bool refresh = false)
        {
            ClubCloud_Baansoort baansoort = new ClubCloud_Baansoort();

            if (SPContext.Current != null && SPContext.Current.Web != null)
            {
                ClubCloudServiceClient client = new ClubCloudServiceClient(SPServiceContext.Current);
                baansoort = client.GetBaansoortById(baansoortId, refresh, new ClubCloud_Setting {
                    Id = int.Parse(bondsnummer), VerenigingId = verenigingId
                });                                                                                                                                           //, accommodatieId, baansoortId, refresh);
            }

            return(baansoort);
        }
Ejemplo n.º 7
0
        public bool SetBaanblokkenForBaansoort(List <ClubCloud_Baanblok> Baanblokken, ClubCloud_Baansoort entity, bool refresh = false, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            bool succes = false;
            ClubCloud_Baansoort result = null;

            using (new SPMonitoredScope("Baansoorten SetBaanblokkenForBaansoort"))
            {
                try
                {
                    entity = beheerModel.ClubCloud_Baansoorten.Find(entity.Id);

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

                    if (result != null)
                    {
                        //return result.ClubCloud_Baansoorten.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);
        }
Ejemplo n.º 8
0
        public bool SetBaantypeForBaansoortById(ClubCloud_Baantype Baantype, System.Guid Id, bool refresh = false, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            ClubCloud_Baansoort entity = null;
            bool succes = false;

            using (new SPMonitoredScope("Baansoorten SetBaantypeForBaansoortById"))
            {
                try
                {
                    entity = beheerModel.ClubCloud_Baansoorten.Find(Id);

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

                    if (entity != null)
                    {
                        entity.ClubCloud_Baantype = Baantype;
                    }

                    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 void UpdateBaansoort(ClubCloud_Baansoort entity)
        {
            using (new SPMonitoredScope("Baansoorten UpdateBaansoort"))
            {
                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.SetBaansoort(entity, Settings);
                        this.OnDataSourceViewChanged(EventArgs.Empty);
                    }
                }
            }
        }
Ejemplo n.º 10
0
        public bool DeleteBaansoort(ClubCloud_Baansoort entity)
        {
            using (new SPMonitoredScope("Baansoorten DeleteBaansoort"))
            {
                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.DeleteBaansoort(entity, Settings));
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 11
0
        public ClubCloud_Baansoort SetBaansoort(ClubCloud_Baansoort entity, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            ClubCloud_Baansoort tobeupdated = null;

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

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

                    beheerModel.SaveChanges();

                    tobeupdated = beheerModel.ClubCloud_Baansoorten.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);
        }
Ejemplo n.º 12
0
        public bool DeleteBaansoortById(System.Guid Id, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            bool succes = false;
            ClubCloud_Baansoort tobedeleted = null;

            using (new SPMonitoredScope("Baansoorten DeleteBaansoortById"))
            {
                try
                {
                    tobedeleted = beheerModel.ClubCloud_Baansoorten.Find(Id);

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