public void DeleteCity(int CityId, bool IsRemote) { var city = _dbContext.DictionaryCity.Include(x => x.Location).Where(x => x.DictionaryCityId == CityId).First(); var location = city.Location.ToList(); foreach (var loc in location) { var result = _dbContext.Conference.Where(b => b.LocationId == loc.LocationId); if (result != null) { foreach (var conf in result) { if (IsRemote) { conf.LocationId = 161; } else { conf.LocationId = 162; } } } _dbContext.Remove(loc); } _dbContext.Remove(city); _dbContext.SaveChanges(); }
public bool DeleteType(int TypeId, bool IsRemote) { try { _dbContext.Remove(_dbContext.DictionaryConferenceType.First(a => a.DictionaryConferenceTypeId == TypeId)); _dbContext.SaveChanges(); return(true); } catch { return(false); } }
public void AddSpeaker(string Email, string Name, string Nationality) { Speaker newSpeaker = new Speaker(); newSpeaker.SpeakerEmail = Email; newSpeaker.SpeakerName = Name; newSpeaker.Nationality = Nationality; _dbContext.Speaker.Add(newSpeaker); _dbContext.SaveChanges(); }
public void EditCounty(string Code, string Name, int CountyId) { var result = _dbContext.DictionaryCounty.SingleOrDefault(b => b.DictionaryCountyId == CountyId); if (result != null) { result.DictionaryCountyName = Name; result.DictionaryCountyCode = Code; _dbContext.SaveChanges(); } }
public void AddCategory(string Name) { int id = _dbContext.DictionaryConferenceCategory.Max(a => a.DictionaryConferenceCategoryId); id += 1; object Category = new DictionaryConferenceCategory { DictionaryConferenceCategoryId = id, DictionaryConferenceCategoryName = Name }; _dbContext.Add(Category); _dbContext.SaveChanges(); }
public int UpdateParticipant(ConferenceAudienceModel _conferenceAudienceModel) { ConferenceAudience result; if (_conferenceAudienceModel.ConferenceStatusId == 2) { result = _dbContext.ConferenceAudience.SingleOrDefault(x => x.ConferenceId == _conferenceAudienceModel.ConferenceId && x.Participant == _conferenceAudienceModel.Participant && (x.ConferenceStatusId == 3 || x.ConferenceStatusId == 1)); } else { result = _dbContext.ConferenceAudience.SingleOrDefault(x => x.ConferenceId == _conferenceAudienceModel.ConferenceId && x.Participant == _conferenceAudienceModel.Participant); } if (result != null) { result.ConferenceStatusId = _conferenceAudienceModel.ConferenceStatusId; _dbContext.SaveChanges(); return(1); } return(0); }
public void DeleteCountry(int CountryId, bool IsRemote) { var country = _dbContext.DictionaryCountry.Where(x => x.DictionaryCountryId == CountryId).FirstOrDefault(); var countys = _dbContext.DictionaryCounty.Where(x => x.DictionaryCountryId == CountryId).ToList(); foreach (var county in countys) { var cities = _dbContext.DictionaryCity.Where(x => x.DictionaryCountyId == county.DictionaryCountyId).ToList(); foreach (var city in cities) { var location = _dbContext.Location.Where(x => x.CityId == city.DictionaryCityId).ToList(); foreach (var loc in location) { var result = _dbContext.Conference.Where(b => b.LocationId == loc.LocationId).Include(x => x.ConferenceType).ToList(); if (result != null) { foreach (var conf in result) { if (conf.ConferenceType.IsRemote) { conf.LocationId = 161; } else { conf.LocationId = 162; } } } _dbContext.Remove(loc); } _dbContext.Remove(city); } _dbContext.Remove(county); } _dbContext.Remove(country); _dbContext.SaveChanges(); }