예제 #1
0
        public async Task <LunchSpot> CreateLunchSpotAsync(string lunchSpotName, Cuisine cuisine)
        {
            var targetCuisine = await _cuisineServices.ListCuisines(x => x.Name.EqualsIgnoreCase(cuisine?.Name))
                                .Extend()
                                .SingleOrThrowAsync <CuisineNotFoundException>();

            var lunchSpot = new LunchRoulette.DatabaseLayer.Entities.LunchSpot
            {
                Name      = lunchSpotName.ToTitleCase(),
                CuisineId = targetCuisine.Id
            };
            await _context.AddAsync(lunchSpot);

            await _context.SaveChangesAsync();

            return(new LunchSpot(lunchSpot)
            {
                Cuisine = targetCuisine
            });
        }
예제 #2
0
 public LunchSpot(LunchRoulette.DatabaseLayer.Entities.LunchSpot lunchSpot)
 {
     Id      = lunchSpot.Id;
     Name    = lunchSpot.Name;
     Cuisine = lunchSpot.Cuisine != null ? new Cuisine(lunchSpot.Cuisine) : null;
 }