コード例 #1
0
        public List <ClubCloud_Baanblok> GetBaanblokkenForBaantypeById(System.Guid Id, bool refresh = false, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

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

            using (new SPMonitoredScope("Baantypes GetBaanblokkenForBaantypeById"))
            {
                try
                {
                    entity = beheerModel.ClubCloud_Baantypes.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 = GetBaanblokkenForBaantypeById(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>());
        }
コード例 #2
0
        public bool DeleteBaantype(ClubCloud_Baantype entity, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            return(DeleteBaantypeById(entity.Id, settings));
        }
コード例 #3
0
        public ClubCloud_Baantype SelectBaantype([QueryString] Guid?Id)  //(string Id)
        {
            ClubCloud_Baantype entity = null;

            using (new SPMonitoredScope("Baantypes SelectBaantype"))
            {
                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.GetBaantypeById(Id.Value, false, Settings);

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

            return(entity);
        }
コード例 #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());
        }
コード例 #5
0
        public async Task <Models.Baantype> GetBaantypeAsync(Guid verenigingId, Guid accommodatieId, Guid baantypeId)
        {
            Models.Baantype _baantype = new Models.Baantype();

            ClubCloud_Baantype baantype = await client.GetBaantypeByIdAsync("0000000", verenigingId, accommodatieId, baantypeId, false);

            _baantype = new Models.Baantype {
                Id = baantype.Id, Naam = baantype.Naam, Beschrijving = baantype.Beschrijving, Code = baantype.Code, Meervoud = baantype.Meervoud, Omschrijving = baantype.Omschrijving
            };

            return(_baantype);
        }
コード例 #6
0
        public ClubCloud_Baantype GetBaantypeById(string bondsnummer, Guid verenigingId, Guid accommodatieId, Guid baantypeId, bool refresh = false)
        {
            ClubCloud_Baantype baantype = new ClubCloud_Baantype();

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

            return(baantype);
        }
コード例 #7
0
        public bool SetBaanblokkenForBaantype(List <ClubCloud_Baanblok> Baanblokken, ClubCloud_Baantype entity, bool refresh = false, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            bool succes = false;
            ClubCloud_Baantype result = null;

            using (new SPMonitoredScope("Baantypes SetBaanblokkenForBaantype"))
            {
                try
                {
                    entity = beheerModel.ClubCloud_Baantypes.Find(entity.Id);

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

                    if (result != null)
                    {
                        //return result.ClubCloud_Baantypes.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);
        }
コード例 #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);
        }
コード例 #9
0
        public void UpdateBaantype(ClubCloud_Baantype entity)
        {
            using (new SPMonitoredScope("Baantypes UpdateBaantype"))
            {
                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.SetBaantype(entity, Settings);
                        this.OnDataSourceViewChanged(EventArgs.Empty);
                    }
                }
            }
        }
コード例 #10
0
        public bool DeleteBaantype(ClubCloud_Baantype entity)
        {
            using (new SPMonitoredScope("Baantypes DeleteBaantype"))
            {
                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.DeleteBaantype(entity, Settings));
                    }
                }
            }
            return(false);
        }
コード例 #11
0
        public ClubCloud_Baantype GetBaantypeById(System.Guid Id, bool refresh = false, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            ClubCloud_Baantype result = null;

            using (new SPMonitoredScope("Baantypes GetBaantypeById"))
            {
                try
                {
                    result = beheerModel.ClubCloud_Baantypes.Find(Id);

                    if (result == null || refresh)
                    {
                        result = GetBaantypeById(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_Baantype());
        }
コード例 #12
0
        public ClubCloud_Baantype SetBaantype(ClubCloud_Baantype entity, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            ClubCloud_Baantype tobeupdated = null;

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

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

                    beheerModel.SaveChanges();

                    tobeupdated = beheerModel.ClubCloud_Baantypes.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);
        }
コード例 #13
0
        public bool DeleteBaantypeById(System.Guid Id, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            bool succes = false;
            ClubCloud_Baantype tobedeleted = null;

            using (new SPMonitoredScope("Baantypes DeleteBaantypeById"))
            {
                try
                {
                    tobedeleted = beheerModel.ClubCloud_Baantypes.Find(Id);

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