public void UpdateBaanblok(ClubCloud_Baanblok entity) { using (new SPMonitoredScope("Baanblokken UpdateBaanblok")) { 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) { entity.AccommodatieId = Settings.ClubCloud_Vereniging.AccommodatieId.Value; } Client.SetBaanblok(entity, Settings); this.OnDataSourceViewChanged(EventArgs.Empty); } } } }
public List <ClubCloud_Baan> GetBanenForBaanblokById(System.Guid Id, bool refresh = false, ClubCloud_Setting settings = null) { if (settings != null) { ValidateSettings(ref settings); } ClubCloud_Baanblok entity = null; List <ClubCloud_Baan> result = null; using (new SPMonitoredScope("Baanblokken GetBanenForBaanblokById")) { try { entity = beheerModel.ClubCloud_Baanblokken.Find(Id); if (entity != null && entity.ClubCloud_Baan != null && entity.ClubCloud_Baan.Count == 0) { beheerModel.Entry(entity).Collection(e => e.ClubCloud_Baan).Load(); } if (entity != null) { result = entity.ClubCloud_Baan.ToList(); } if (result == null || result.Count == 0 || refresh) { result = GetBanenForBaanblokById(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_Baan>()); }
public ClubCloud_Baanblok SelectBaanblok([QueryString] Guid?Id) //(string Id) { ClubCloud_Baanblok entity = null; using (new SPMonitoredScope("Baanblokken SelectBaanblok")) { 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.GetBaanblokById(Id.Value, false, Settings); if (entity != null || entity.Id != Guid.Empty) { entity.ClubCloud_Baan = new System.Collections.ObjectModel.ObservableCollection <ClubCloud_Baan>(Client.GetBanenForBaanblokById(Id.Value, false, Settings)); entity.ClubCloud_Accommodatie = Client.GetAccommodatieForBaanblokById(Id.Value, false, Settings); entity.ClubCloud_Baantype = Client.GetBaantypeForBaanblokById(Id.Value, false, Settings); entity.ClubCloud_Baansoort = Client.GetBaansoortForBaanblokById(Id.Value, false, Settings); } } } } } return(entity); }
public bool DeleteBaanblok(ClubCloud_Baanblok entity, ClubCloud_Setting settings = null) { if (settings != null) { ValidateSettings(ref settings); } return(DeleteBaanblokById(entity.Id, settings)); }
public ClubCloud_Baanblok GetBaanblokForBaanById(System.Guid Id, bool refresh = false, ClubCloud_Setting settings = null) { if (settings != null) { ValidateSettings(ref settings); } ClubCloud_Baan entity = null; ClubCloud_Baanblok result = null; using (new SPMonitoredScope("Banen GetBaanblokForBaanById")) { try { entity = beheerModel.ClubCloud_Banen.Find(Id); if (entity != null && entity.ClubCloud_Baanblok == null) { beheerModel.Entry(entity).Reference(e => e.ClubCloud_Baanblok).Load(); } if (entity != null) { result = entity.ClubCloud_Baanblok; } if (result == null || refresh) { result = GetBaanblokForBaanById(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_Baanblok()); }
public ClubCloud_Accommodatie GetAccommodatieForBaanblok(ClubCloud_Baanblok entity, bool refresh = false, ClubCloud_Setting settings = null) { if (settings != null) { ValidateSettings(ref settings); } ClubCloud_Accommodatie result = null; using (new SPMonitoredScope("Baanblokken GetAccommodatieForBaanblok")) { try { entity = beheerModel.ClubCloud_Baanblokken.Find(entity.Id); if (entity != null && entity.ClubCloud_Accommodatie == null) { beheerModel.Entry(entity).Reference(e => e.ClubCloud_Accommodatie).Load(); } if (entity != null) { result = entity.ClubCloud_Accommodatie; } if (result == null || refresh && entity != null) { result = GetAccommodatieForBaanblok(settings.Id.ToString(), entity, 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_Accommodatie()); }
public bool SetBaanblokForBaanById(ClubCloud_Baanblok Baanblok, System.Guid Id, bool refresh = false, ClubCloud_Setting settings = null) { if (settings != null) { ValidateSettings(ref settings); } ClubCloud_Baan entity = null; bool succes = false; using (new SPMonitoredScope("Banen SetBaanblokForBaanById")) { try { entity = beheerModel.ClubCloud_Banen.Find(Id); if (entity != null && entity.ClubCloud_Baanblok == null) { beheerModel.Entry(entity).Reference(e => e.ClubCloud_Baanblok).Load(); } if (entity != null) { entity.ClubCloud_Baanblok = Baanblok; } 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 SetBanenForBaanblok(List <ClubCloud_Baan> Banen, ClubCloud_Baanblok entity, bool refresh = false, ClubCloud_Setting settings = null) { if (settings != null) { ValidateSettings(ref settings); } bool succes = false; ClubCloud_Baanblok result = null; using (new SPMonitoredScope("Baanblokken SetBanenForBaanblok")) { try { entity = beheerModel.ClubCloud_Baanblokken.Find(entity.Id); if (entity != null) { beheerModel.Entry(entity).Collection(e => e.ClubCloud_Baan).Load(); } //result = GetBaanblokById(settings.Id.ToString(), Id, refresh, settings); if (result != null) { //return result.ClubCloud_Baanblokken.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 DeleteBaanblok(ClubCloud_Baanblok entity) { using (new SPMonitoredScope("Baanblokken DeleteBaanblok")) { 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.DeleteBaanblok(entity, Settings)); } } } return(false); }
public ClubCloud_Baanblok SetBaanblok(ClubCloud_Baanblok entity, ClubCloud_Setting settings = null) { if (settings != null) { ValidateSettings(ref settings); } ClubCloud_Baanblok tobeupdated = null; using (new SPMonitoredScope("Baanblokken SetBaanblok")) { try { entity = SetBaanblok(settings.Id.ToString(), entity, settings); if (entity != null) { beheerModel.ClubCloud_Baanblokken.AddOrUpdate(entity); } beheerModel.SaveChanges(); tobeupdated = beheerModel.ClubCloud_Baanblokken.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 bool DeleteBaanblokById(System.Guid Id, ClubCloud_Setting settings = null) { if (settings != null) { ValidateSettings(ref settings); } bool succes = false; ClubCloud_Baanblok tobedeleted = null; using (new SPMonitoredScope("Baanblokken DeleteBaanblokById")) { try { tobedeleted = beheerModel.ClubCloud_Baanblokken.Find(Id); if (tobedeleted != null) { beheerModel.ClubCloud_Baanblokken.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); }