Esempio n. 1
0
        public async Task <IEnumerable <RewardDTO> > GetRewardList(object Id)
        {
            var lst   = new List <RewardDTO>();
            var users = await _userDal.GetAsync(x => x.Id == new ObjectId((string)Id));

            var restList = await _restaurantDal.GetAllAsync();

            if (users == null)
            {
                throw new HttpStatusCodeException(StatusCodes.Status404NotFound, "Kullanıcı Bulunamadı..!!");
            }



            foreach (var reward in users.Reward)
            {
                var rest = restList.FirstOrDefault(x => x.Promotion.Any(z => z.Id == reward.PromotionId));
                if (rest == null)
                {
                    continue;
                }

                var promotion = rest.Promotion.FirstOrDefault(z => z.Id == reward.PromotionId);
                if (promotion == null)
                {
                    continue;
                }

                var product = rest.Product.FirstOrDefault(x => x.Id == promotion.ProductId);
                if (product == null)
                {
                    continue;
                }

                lst.Add(new RewardDTO
                {
                    Claim       = reward.ClaimCount,
                    isUsed      = reward.isUsed,
                    RestId      = rest.Id.ToString(),
                    RestName    = rest.Name,
                    ProductName = product.Description,
                    ProductId   = product.Id.ToString(),
                    StampDate   = reward.StampDate
                });
            }

            return(lst);
        }
Esempio n. 2
0
        public async Task <List <ImageDTO> > GetApprovedImage()
        {
            var lst  = new List <ImageDTO>();
            var rest = await _restaurantDal.GetAllAsync();

            if (rest == null)
            {
                throw new HttpStatusCodeException(StatusCodes.Status404NotFound, "Ödül Bulunumadı..!!");
            }

            foreach (var item in rest)
            {
                if (item.Images == null)
                {
                    continue;
                }
                foreach (var m in item.Images.Where(x => x.Statu == StatusType.Approved).ToList())
                {
                    lst.Add(new ImageDTO()
                    {
                        Id       = m.Id.ToString(),
                        Statu    = m.Statu.ToString(),
                        Data     = m.Image,
                        Info     = m.Description,
                        RestName = item.Name,
                        RestId   = item.Id.ToString()
                    });
                }
            }
            return(lst);
        }