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

            ClubCloud_Functie             entity = null;
            List <ClubCloud_Functionaris> result = null;

            using (new SPMonitoredScope("Functies GetFunctionarissenForFunctieById"))
            {
                try
                {
                    entity = beheerModel.ClubCloud_Functies.Find(Id);
                    if (entity != null && entity.ClubCloud_Functionaris != null && entity.ClubCloud_Functionaris.Count == 0)
                    {
                        beheerModel.Entry(entity).Collection(e => e.ClubCloud_Functionaris).Load();
                    }

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

                    if (result == null || result.Count == 0 || refresh)
                    {
                        result = GetFunctionarissenForFunctieById(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_Functionaris>());
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="functie"></param>
        /// <param name="settings"></param>
        /// <returns></returns>
        private async Task <bool> CreateOrUpdateRoleFunctie(ClubCloud_Functie functie, ClubCloud_Setting settings = null)
        {
            try
            {
                if (settings == null)
                {
                    return(false);
                }

                if (settings != null)
                {
                    if (await ZimbraRoleProvider.RoleExistsAsync(functie.Naam))
                    {
                        return(true);
                    }

                    await ZimbraRoleProvider.CreateRoleAsync(functie.Naam);
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
예제 #3
0
        public bool DeleteFunctie(ClubCloud_Functie entity, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            return(DeleteFunctieById(entity.Id, settings));
        }
예제 #4
0
        public ClubCloud_Functie SelectFunctie([QueryString] Guid?Id)  //(string Id)
        {
            ClubCloud_Functie entity = null;

            using (new SPMonitoredScope("Functies SelectFunctie"))
            {
                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.GetFunctieById(Id.Value, false, Settings);

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

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

            ClubCloud_Functionaris entity = null;
            ClubCloud_Functie      result = null;

            using (new SPMonitoredScope("Functionarissen GetFunctieForFunctionarisById"))
            {
                try
                {
                    entity = beheerModel.ClubCloud_Functionarissen.Find(Id);
                    if (entity != null && entity.ClubCloud_Functie == null)
                    {
                        beheerModel.Entry(entity).Reference(e => e.ClubCloud_Functie).Load();
                    }

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

                    if (result == null || refresh)
                    {
                        result = GetFunctieForFunctionarisById(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_Functie());
        }
예제 #6
0
        public bool SetFunctionarissenForFunctie(List <ClubCloud_Functionaris> Functionarissen, ClubCloud_Functie entity, bool refresh = false, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            bool succes = false;
            ClubCloud_Functie result = null;

            using (new SPMonitoredScope("Functies SetFunctionarissenForFunctie"))
            {
                try
                {
                    entity = beheerModel.ClubCloud_Functies.Find(entity.Id);

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

                    if (result != null)
                    {
                        //return result.ClubCloud_Functies.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 SetFunctieForFunctionarisById(ClubCloud_Functie Functie, System.Guid Id, bool refresh = false, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            ClubCloud_Functionaris entity = null;
            bool succes = false;

            using (new SPMonitoredScope("Functionarissen SetFunctieForFunctionarisById"))
            {
                try
                {
                    entity = beheerModel.ClubCloud_Functionarissen.Find(Id);

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

                    if (entity != null)
                    {
                        entity.ClubCloud_Functie = Functie;
                    }

                    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);
        }
예제 #8
0
        public void UpdateFunctie(ClubCloud_Functie entity)
        {
            using (new SPMonitoredScope("Functies UpdateFunctie"))
            {
                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.SetFunctie(entity, Settings);
                        this.OnDataSourceViewChanged(EventArgs.Empty);
                    }
                }
            }
        }
예제 #9
0
        public bool DeleteFunctie(ClubCloud_Functie entity)
        {
            using (new SPMonitoredScope("Functies DeleteFunctie"))
            {
                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.DeleteFunctie(entity, Settings));
                    }
                }
            }
            return(false);
        }
예제 #10
0
        public ClubCloud_Functie GetFunctieById(System.Guid Id, bool refresh = false, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            ClubCloud_Functie result = null;

            using (new SPMonitoredScope("Functies GetFunctieById"))
            {
                try
                {
                    result = beheerModel.ClubCloud_Functies.Find(Id);

                    if (result == null || refresh)
                    {
                        result = GetFunctieById(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_Functie());
        }
예제 #11
0
        public ClubCloud_Functie SetFunctie(ClubCloud_Functie entity, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            ClubCloud_Functie tobeupdated = null;

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

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

                    beheerModel.SaveChanges();

                    tobeupdated = beheerModel.ClubCloud_Functies.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);
        }
예제 #12
0
        public bool DeleteFunctieById(System.Guid Id, ClubCloud_Setting settings = null)
        {
            if (settings != null)
            {
                ValidateSettings(ref settings);
            }

            bool succes = false;
            ClubCloud_Functie tobedeleted = null;

            using (new SPMonitoredScope("Functies DeleteFunctieById"))
            {
                try
                {
                    tobedeleted = beheerModel.ClubCloud_Functies.Find(Id);

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