public async Task<IHttpActionResult> GetRelatedArticles(int id) { ArticlesProvider articlesProvider = new ArticlesProvider(); IEnumerable<ArticleModel> relatedArticles = await articlesProvider.GetRelatedArticles(id); if (relatedArticles == null) { return this.NotFound(); } return this.Ok(relatedArticles); }
public async Task<bool> ValidateOrderedItem(OrderedItemModel orderedItem) { ArticlesProvider articlesProvider = new ArticlesProvider(); Task<bool> articleExistsTask = articlesProvider.HasArticleWithPrice(orderedItem.ArticleId.Value, orderedItem.Price.Value); StocksProvider stocksProvider = new StocksProvider(); Task<bool> hasStocksTask = stocksProvider.HasEnoughStocksOfArticle(orderedItem.ArticleId.Value, orderedItem.SizeId.Value, orderedItem.ColorId, orderedItem.Quantity.Value); bool articleExists = await articleExistsTask; bool hasEnoughStocks = await hasStocksTask; bool isOrderValid = articleExists && hasEnoughStocks; return isOrderValid; }
public async Task<IHttpActionResult> Get(string categoryUrl, string orderBy, SortDirection sortDirection, string filter = null) { Guid? currentUserId = null; if (this.User.Identity.IsAuthenticated) { currentUserId = new Guid(this.User.Identity.GetUserId()); } ArticlesProvider articlesProvider = new ArticlesProvider(); ArticlesListModel articlesList = await articlesProvider.GetArticlesInCategory(categoryUrl, filter, orderBy, sortDirection, currentUserId); if (articlesList == null) { return this.NotFound(); } return this.Ok(articlesList); }
public async Task<IHttpActionResult> GetDiscountedArticles() { Guid? currentUserId = null; if (this.User.Identity.IsAuthenticated) { currentUserId = new Guid(this.User.Identity.GetUserId()); } ArticlesProvider articlesProvider = new ArticlesProvider(); IEnumerable<ArticleModel> discountedArticles = await articlesProvider.GetDiscountedArticles(currentUserId); if (discountedArticles == null) { return this.NotFound(); } return this.Ok(discountedArticles); }
public async Task<IHttpActionResult> Get(int collectionId) { Guid? currentUserId = null; if (this.User.Identity.IsAuthenticated) { currentUserId = new Guid(this.User.Identity.GetUserId()); } ArticlesProvider articlesProvider = new ArticlesProvider(); IEnumerable<ArticleModel> articlesInCollection = await articlesProvider.GetArticlesInCollection(collectionId, currentUserId); if (articlesInCollection == null) { return this.NotFound(); } return this.Ok(articlesInCollection); }
public IHttpActionResult Get(string urlName) { Guid? currentUserId = null; if (this.User.Identity.IsAuthenticated) { currentUserId = new Guid(this.User.Identity.GetUserId()); } ArticlesProvider articlesProvider = new ArticlesProvider(); FullArticleModel articleModel = articlesProvider.GetFullArticleByUrlName(urlName, currentUserId); if (articleModel == null) { return this.NotFound(); } return this.Ok(articleModel); }
public LikesMediator(ArticlesProvider articlesProvider, UserLikesProvider userLikesProvider) { this.articlesProvider = articlesProvider; this.userLikesProvider = userLikesProvider; }
public async Task<IHttpActionResult> GetLikedArticles() { ArticlesProvider articlesProvider = new ArticlesProvider(); IEnumerable<ArticleModel> likedArticles = await articlesProvider.GetLikedArticles(new Guid(this.User.Identity.GetUserId())); if (likedArticles == null) { return this.NotFound(); } return this.Ok(likedArticles); }