static void Main(string[] args) { using (SqlRepository repository = new SqlRepository()) { // foreach (var item in repository.GetAll()) // { // Console.WriteLine(item); // } if (repository.AddNew("Avok2adoes", "Gröne Avoks2ado", 129) > 0) { Console.WriteLine("Frukt tillagd"); } else { Console.WriteLine("Ingen frukt tillagd"); } List <Fruit> fruits = repository.GetAll(); var q = fruits.FirstOrDefault(x => x.FruitType == "Avokado"); Console.WriteLine(q); } }
public EmployeeListViewModel() { using (var datacontext = new ShopDbEntities()) { _employeeRepository = new SqlRepository <Employee>(datacontext); var query = from employee in _employeeRepository.GetAll().AsEnumerable() select employee; EmployeeList = query.ToList(); } }
public void Test(string startsWith, string endsWith) { ISqlRepository repo = new SqlRepository("sqlDefaultConnection2"); var branches = repo.GetAll<Branche>(); var branch = repo.FindSingle<Branche>(b => b.Id == 1); branches = repo.Find<Branche>(b => b.Address2.EndsWith(endsWith) && b.Name == "البيداء"); branches = repo.Find<Branche>(b => b.Address2.StartsWith(startsWith)); branches = repo.Find<Branche>(b => b.Address2 == null); }
public void Test(string startsWith, string endsWith) { ISqlRepository repo = new SqlRepository("sqlDefaultConnection"); var branches = repo.GetAll <Branch>(); var branch = repo.FindAll <Branch>(b => b.Id == 1); branches = repo.FindAll <Branch>(b => b.Address2.EndsWith(endsWith) && b.Name == "البيداء"); branches = repo.FindAll <Branch>(b => b.Address2.StartsWith(startsWith)); branches = repo.FindAll <Branch>(b => b.Address2 == null); }
public void Test() { ISqlRepository repo = new SqlRepository("sqlDefaultConnection"); var branches = repo.GetAll <Branch>(); var branch = repo.FindAll <Branch>(b => b.Id == 1); branches = repo.FindAll <Branch>(b => b.Address2.EndsWith("Munawwarah") && b.Name == "البيداء"); branches = repo.FindAll <Branch>(b => b.Address2.StartsWith("Al Madina")); branches = repo.FindAll <Branch>(b => b.Address2 == null); var bs = new List <Branch>(); }
private MinionContext InitializeContext() { // lazy static constructor for the DB will not get executed until this point, out of the FinishedLoading // allowing the application to respond as quick as it can. var minionContext = new MinionContext(DB.Main, new ObservableDomainEventBus()); var minionRepo = new SqlRepository<MinionContract>(DB.Main); var allMinions = minionRepo.GetAll(); if (!allMinions.Any()) { // bootstrap us some var cmd = minionContext.NewCommandExecutor<MinionAggregate>(); cmd.Execute(new ChangeNameCommand {AggregateId = MinionId.NewId(), Name = "Minion 1" }); cmd.Execute(new ChangeNameCommand {AggregateId = MinionId.NewId(), Name = "Minion 2" }); cmd.Execute(new ChangeNameCommand {AggregateId = MinionId.NewId(), Name = "Minion 3" }); } return minionContext; }
public IEnumerable <Shot> GetAll() { return(_sqlRepository.GetAll().ToList().Select(_selector)); }
public IEnumerable <ShooterParticipation> GetAll() { return(_sqlRepository.GetAll().ToList().Select(_selector)); }
public IEnumerable <Category> GetAll() { SqlRepository <Category> rep = new SqlRepository <Category>(new SqlServerDefaultContext()); return(rep.GetAll()); }
public IEnumerable <T> GetAll <T>() where T : IOrmGenerated { using (var rep = new SqlRepository(_Configuration, _Logger)) return(rep.GetAll <T>()); }
static async Task Main(string[] args) { string input = ""; Dictionary <string, Category> categoryLookup = new Dictionary <string, Category>() { { "wishlist", Category.Wishlist }, { "collection", Category.Collection } }; IFileAccess azureFileAccess = new AzureFileAccess(Constants.AzureFileConnectionString, Constants.AzureFileShareName); IFileAccess localFileAccess = new LocalFileAccess(); IAlbumRepository repository = new SqlRepository(Constants.DbConnectionString); // IAlbumRepository repository = new JsonRepository(Constants.AzureFileFilepath, azureFileAccess); //IAlbumRepository repository = new JsonRepository(Constants.LocalFilePath, localFileAccess); //IAlbumRepository repository = new CosmosRepository(Constants.CosmosEndpointUri, Constants.CosmosPrimaryKey, Constants.CosmosDatabaseId, Constants.CosmosContainerId); while (input != "9") { Console.WriteLine("Main Menu"); Console.WriteLine("1. Enter new Album"); Console.WriteLine("2. Edit Album"); Console.WriteLine("3. Display All"); Console.WriteLine("4. Display Wishlist"); Console.WriteLine("5. Display Collection"); Console.WriteLine("6. Display filtered albums"); Console.WriteLine("7. Display Totals"); Console.WriteLine("8. Delete Album"); Console.WriteLine("9. Exit"); input = Console.ReadLine(); if (input == "1") { Console.Write("Artist: "); string artist = Console.ReadLine(); Console.Write("Title: "); string title = Console.ReadLine(); Console.Write("Year: "); int year = 0; int.TryParse(Console.ReadLine(), out year); Console.Write("Format: "); string format = Console.ReadLine(); Console.Write("Store: "); string store = Console.ReadLine(); decimal price = 0; Console.Write("Price: "); decimal.TryParse(Console.ReadLine(), out price); Console.Write("Symbol: "); string symbol = Console.ReadLine(); Console.Write("Location: "); string location = Console.ReadLine(); Category c = Category.Wishlist; categoryLookup.TryGetValue(location.ToLower(), out c); await repository.Add(new Album() { Id = 0, Artist = artist, Title = title, Year = year == 0 ? "" : year.ToString(), Format = format, Store = store, Price = price, Symbol = symbol, Location = c }); } else if (input == "2") { int id = 0; Console.WriteLine("Edit Album"); Console.Write("Id to edit: "); int.TryParse(Console.ReadLine(), out id); Album e = await repository.GetBy(id); if (e != null) { string artist = e.Artist; string title = e.Title; string year = e.Year; string format = e.Format; string store = e.Store; decimal price = e.Price; string symbol = e.Symbol; Category location = e.Location; Console.Write("Artist (" + artist + "): "); string artistIn = Console.ReadLine(); if (!string.IsNullOrEmpty(artistIn)) { e.Artist = artistIn; } Console.Write("Title (" + title + "): "); string titleIn = Console.ReadLine(); if (!string.IsNullOrEmpty(titleIn)) { e.Title = titleIn; } Console.Write("Year (" + year + "): "); string yearIn = Console.ReadLine(); if (!string.IsNullOrEmpty(yearIn)) { int y = 0; int.TryParse(yearIn, out y); e.Year = y == 0 ? "" : y.ToString(); } Console.Write("Format (" + format + "): "); string formatIn = Console.ReadLine(); if (!string.IsNullOrEmpty(formatIn)) { e.Format = formatIn; } Console.Write("Store (" + store + "): "); string storeIn = Console.ReadLine(); if (!string.IsNullOrEmpty(storeIn)) { e.Store = storeIn; } Console.Write("Price (" + price + "): "); string priceIn = Console.ReadLine(); if (!string.IsNullOrEmpty(priceIn)) { decimal p = 0; decimal.TryParse(priceIn, out p); e.Price = p; } Console.Write("Symbol (" + symbol + "): "); string symbolIn = Console.ReadLine(); if (!string.IsNullOrEmpty(symbolIn)) { e.Symbol = symbolIn; } Console.Write("Location (" + location + "): "); string locationIn = Console.ReadLine(); if (!string.IsNullOrEmpty(locationIn)) { Category c = Category.Wishlist; categoryLookup.TryGetValue(locationIn.ToLower(), out c); e.Location = c; } await repository.Edit(e); } else { Console.WriteLine("Could not find album with id = " + id); } } else if (input == "3") { printAlbums(await repository.GetAll()); } else if (input == "4") { printAlbums(repository.GetAll().Result.Where(a => a.Location == Category.Wishlist)); } else if (input == "5") { printAlbums(repository.GetAll().Result.Where(a => a.Location == Category.Collection)); } else if (input == "6") { Console.Write("Filter Expression: "); string filter = Console.ReadLine(); // var result = repository.GetFilteredAlbums(filter); var result = GetFilteredAlbums(filter, repository.GetAll().Result); printAlbums(result); } else if (input == "7") { decimal wishListTotal = repository.GetAll().Result.Where(a => a.Location == Category.Wishlist).Sum(a => a.Price); decimal collectionTotal = repository.GetAll().Result.Where(a => a.Location == Category.Collection).Sum(a => a.Price); Console.WriteLine("Wishlist total: " + wishListTotal.ToString("C", CultureInfo.CurrentCulture)); Console.WriteLine("Collection total: " + collectionTotal.ToString("C", CultureInfo.CurrentCulture)); } else if (input == "8") { Console.WriteLine("Delete album"); Console.Write("Id to delete: "); string id = Console.ReadLine(); int parsedId = 0; if (!int.TryParse(id, out parsedId)) { Console.WriteLine("Id must be a number"); continue; } var a = await repository.GetBy(parsedId); if (a != null) { Console.WriteLine("*** WARNING *** This operation cannot be undone. Please type the name of the album to delete below"); string titleToDelete = Console.ReadLine(); if (a.Title == titleToDelete) { await repository.Delete(a.Id); } else { Console.WriteLine("Album not found, nothing deleted"); } } } else if (input == "9") { Console.WriteLine("Bye"); } } }
public IEnumerable <CollectionShooter> GetAll() { return(_sqlRepository.GetAll().ToList().Select(_selector)); }
public IEnumerable <Product> GetAll() { SqlRepository <Product> rep = new SqlRepository <Product>(new SqlServerDefaultContext()); return(rep.GetAll()); }