public async Task <IActionResult> Get(string id) { return(await this.Execute(true, false, async() => { PromoDiscountDetailsModel result = await this.promoDiscounts.Get(id); return this.Ok(result); })); }
public async Task <PromoDiscountDetailsModel> Get(string promoId) { if (!await this.db.PromoDiscounts.AnyAsync(d => d.Id == promoId)) { throw new ArgumentException("Cannot find promo in DB"); } PromoDiscountDetailsModel model = await this.db.PromoDiscounts .Where(d => d.Id == promoId) .ProjectTo <PromoDiscountDetailsModel>() .FirstOrDefaultAsync(); model.ProductsIds = await this.GetAssociatedProductsIds(promoId); return(model); }