Exemple #1
0
        public async Task <IEnumerable <RewardDTO> > GetRewardListByRestaurant(object Id, object RestId)
        {
            var lst   = new List <RewardDTO>();
            var users = await _userDal.GetAsync(x => x.Id == new ObjectId((string)Id));

            var rest = await _restaurantDal.GetAsync(x => x.Id == new ObjectId((string)RestId));

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

            foreach (var reward in users.Reward)
            {
                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);
        }
        public async Task SaveRestaurantInfo(RestaurantInfoDTO item)
        {
            var rest = await _restaurantDal.GetAsync(x => x.Id == new ObjectId((string)item.Id));

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

            if (rest.Info == null)
            {
                rest.Info = new Info();
            }

            rest.Info.PaymentTypes = item.PaymentTypes;
            rest.Info.WorkingDays  = item.WorkingDays;
            rest.Info.WorkingHours = item.WorkingHours;
            rest.Info.Phone        = item.Phone;

            await UpdateAsync(rest);
        }