Example #1
0
        public async Task <IActionResult> GetItemAttributes([FromQuery] ItemAttributesFilter filter)
        {
            if (filter.MerchantIdentity != null && filter.ItemId != null && filter.WithItem != true)
            {
                var merchant = await _unitOfWork.Merchants.GetMerchantDetailsAsync(filter.MerchantIdentity);

                filter.MerchantIdentity = merchant.MerchantIdentity;
            }
            //For agreement
            if (filter.MerchantIdentity != null && filter.WithItem == true)
            {
                var merchant = await _unitOfWork.Merchants.GetMerchantDetailsAsync(filter.MerchantIdentity);

                filter.MerchantIdentity = merchant.MerchantIdentity;
                var itemAttributeList = await _unitOfWork.ItemAttributes.GetItemAttributes(filter.MerchantIdentity);

                var itemList = await _unitOfWork.Items.GetItems(0);

                var itemAttributeWithItemName = from itemAttribute in itemAttributeList join item in itemList
                                                on itemAttribute.ItemId equals item.ItemId
                                                select new {
                    itemAttribute.InCityRate,
                    itemAttribute.OutCityRate,
                    itemAttribute.ItemSize,
                    itemAttribute.ConditionCharge,
                    itemAttribute.BookingCharge,
                    item.Name
                };
                return(Ok(itemAttributeWithItemName));
            }
            var result = await _unitOfWork.ItemAttributes.GetItemAttributes(filter);

            return(Ok(result));
        }
        public async Task <IEnumerable <ItemAttribute> > GetItemAttributes(ItemAttributesFilter filter)
        {
            var itemAttributes = _context.ItemAttributes.AsQueryable();

            if (filter.ItemId.HasValue)
            {
                itemAttributes = itemAttributes.Where(at => at.ItemId == filter.ItemId);
            }
            if (filter.MerchantIdentity != null)
            {
                itemAttributes = itemAttributes.Where(at => at.MerchantIdentity == filter.MerchantIdentity);
            }
            return(await itemAttributes.ToListAsync());
        }