public IEnumerable <CountryInfo> GetCountryInfos() { using (var dbContext = new HappyDbContext()) { List <CountryInfo> countryInfoList = dbContext.Database.SqlQuery <CountryInfo>("GetCounties").ToList(); return(countryInfoList); } }
public void ClearVotes(string countryId) { using (var dbContext = new HappyDbContext()) { dbContext.CountryVotes.RemoveRange(dbContext.CountryVotes.Where(x => x.CountryId == countryId)); dbContext.SaveChanges(); } }
public void ClearAllVotes() { using (var dbContext = new HappyDbContext()) { dbContext.CountryVotes.RemoveRange(dbContext.CountryVotes); dbContext.SaveChanges(); } }
public void AddCountryVote(CountryVoteRequest countryVoteRequest) { using (var dbContext = new HappyDbContext()) { dbContext.CountryVotes.Add(new CountryVote() { Id = Guid.NewGuid(), Rate = countryVoteRequest.Rate, CountryId = countryVoteRequest.CountryId, IsInhabitant = countryVoteRequest.IsInhabitant, }); dbContext.SaveChanges(); } }
public IEnumerable <IndexInfo> GetCountryTextInfo(string countryId) { using (var dbContext = new HappyDbContext()) { List <Models.Data.IndexInfo> countryIndexInfoList = dbContext.IndexInfos.Where(x => x.CountryId == countryId).ToList(); return(from c in IndexContacts.DefaultIndexInfo join ci in countryIndexInfoList on c.Name equals ci.Name into _ci from ci in _ci.DefaultIfEmpty() select new IndexInfo { Name = c.Name, Details = ci == null ? c.Details : ci.Details, Text = ci == null ? c.Text : ci.Text, WaysToImprove = ci == null ? c.WaysToImprove : ci.WaysToImprove, }); } }