public List <DrinkConfigDto> GetDrinksConfig(UserPass user) { if (!_security.Check(user)) { throw new AuthenticationException(); } var idUser = _security.GetUserId(user); var drinks = new List <DrinkConfigDto>(); using (var context = new BeerControlEntities()) { var producerNames = GetProducerNames(idUser, context); var dbDrinks = context.Drink.Where(d => d.idUser == idUser); foreach (var drink in dbDrinks) { drinks.Add(DtoFactory.Create(drink, producerNames)); } } return(drinks); }
public List <MarketDto> GetMarkets(UserPass user) { if (!_security.Check(user)) { throw new AuthenticationException(); } var idUser = _security.GetUserId(user); var list = new List <MarketDto>(); using (var context = new BeerControlEntities()) { var dbMarkets = context.Market.Where(m => m.idUser == idUser); foreach (var dbMarket in dbMarkets) { list.Add(DtoFactory.Create(dbMarket)); } } return(list); }