public void ClearDb() { using (var context = new FeedMeContext(options)) { context.Detail.RemoveRange(context.Detail); context.SaveChanges(); }; }
public async Task TestGetSuccessfully() { using (var context = new FeedMeContext(options)) { DetailsController detailsController = new DetailsController(context, configuration); ActionResult <IEnumerable <Detail> > result = await detailsController.GetDetail(); Assert.IsNotNull(result); } }
public static void ratingAvg(int id, FeedMeContext context) { List <RatingsObj> ratingList = context.Ratings.Where(x => x.RestaurantId == id).ToList(); double result = 0; foreach (var item in ratingList) { result += item.Note; } result = result / ratingList.Count(); RestaurantsObj restoMaj = context.Restaurants.Where(x => x.IdRestaurant == id).First(); restoMaj.Rating = result; context.SaveChanges(); }
public async Task TestPutMemeItemUpdate() { using (var context = new FeedMeContext(options)) { // Given string title = "putMeme"; Detail memeItem1 = context.Detail.Where(x => x.Title == memeTitles[0]).Single(); memeItem1.Title = title; // When DetailsController memeController = new DetailsController(context, configuration); IActionResult result = await memeController.PutDetail(memeItem1.Id, memeItem1) as IActionResult; // Then memeItem1 = context.Detail.Where(x => x.Title == title).Single(); } }
public async Task TestPutMemeItemNoContentStatusCode() { using (var context = new FeedMeContext(options)) { // Given string title = "putMeme"; Detail memeItem1 = context.Detail.Where(x => x.Title == memeTitles[0]).Single(); memeItem1.Title = title; // When DetailsController memeController = new DetailsController(context, configuration); IActionResult result = await memeController.PutDetail(memeItem1.Id, memeItem1) as IActionResult; // Then Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(NoContentResult)); } }
public void SetupDb() { using (var context = new FeedMeContext(options)) { Detail memeItem1 = new Detail() { Title = memeTitles[0] }; Detail memeItem2 = new Detail() { Title = memeTitles[1] }; context.Detail.Add(memeItem1); context.Detail.Add(memeItem2); context.SaveChanges(); } }
public DetailsController(FeedMeContext context, IConfiguration configuration) { _context = context; _configuration = configuration; }
public SubscriptionsController(FeedMeContext context, UserManager <User> user) { db = context; _userManager = user; }
public SubscriptionService(IConfiguration configuration, FeedMeContext context) { _conf = configuration; db = context; }
public static RestaurantsModify TransformRestoObjIntoRestoModify(RestaurantsObj resto, FeedMeContext context) { string cuisineTypeName = context.CuisineTypes.Where(x => x.IdCuisine == resto.IdCuisine).First().Name; RestaurantsModify restoMod = new RestaurantsModify { Adress = resto.Adress, City = resto.City, CuisineType = cuisineTypeName, IdRestaurant = resto.IdRestaurant, Name = resto.Name, Phone = resto.Phone, PostalCode = resto.PostalCode, urlThumbnail = resto.urlThumbnail }; return(restoMod); }
public static RestaurantsViewDetails TransformRestoObjIntoRestoViewDetails(RestaurantsObj resto, FeedMeContext context) { RestaurantsView restoV = TransformRestoObjIntoRestoView(resto, context); List <ImagesObj> imgList = context.Images.Where(x => x.IdRestaurant == resto.IdRestaurant).ToList(); List <DishesObj> dishesList = context.Dishes.Where(x => x.IdRestaurant == resto.IdRestaurant).ToList(); RestaurantsViewDetails restoD = new RestaurantsViewDetails { Adress = restoV.Adress, City = restoV.City, CuisineType = restoV.CuisineType, IdRestaurant = restoV.IdRestaurant, Name = restoV.Name, Phone = restoV.Phone, PostalCode = restoV.PostalCode, Rating = restoV.Rating, urlThumbnail = restoV.urlThumbnail, Images = imgList, Dishes = dishesList }; return(restoD); }
public FeedController(FeedMeContext context, IFeedService feedService, ISubscriptionService subscriptionService) { db = context; _feed = feedService; _subscription = subscriptionService; }