コード例 #1
0
        // GET: Coupon
        public ActionResult Index()
        {
            var coupons   = couponRepository.GetAll().ToList();
            var couponDTO = Mapper.Map <List <Coupons>, List <CouponsDTO> >(coupons);

            return(Json(couponDTO, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public async Task <ActionResult <List <Coupon> > > GetAll(
            [FromServices] ICouponRepository repository
            )
        {
            var role       = User.Claims.FirstOrDefault(x => x.Type.Equals(ClaimTypes.Role))?.Value;
            var customerId = int.Parse(User.Claims.FirstOrDefault(x => x.Type.Equals(ClaimTypes.NameIdentifier))?.Value);

            if (role == "manager")
            {
                return(Ok(repository.GetAll()));
            }
            return(Ok(repository.GetByCustomerId(customerId)));
        }
コード例 #3
0
        public void CreateBulkTest()
        {
            //            var actualCoupons = feedScraper.GetAll(); //.ToList()
            //
            //            //            var serialized = JsonConvert.SerializeObject(actualCoupons);
            //            //            File.WriteAllText(CouponFilePath, serialized);
            //
            //            var expectedCouponsJson = File.ReadAllText(CouponFilePath, Encoding.UTF8);
            //            List<Coupon> expectedCoupons = JsonConvert.DeserializeObject<List<Coupon>>(expectedCouponsJson);

            List <Coupon> coupons = couponRepo.GetAll().ToList();

            CollectionAssert.AreEqual(coupons, coupons);
        }
コード例 #4
0
        public async Task <IEnumerable <Booking> > Get()
        {
            var bookings = (await bookingRepository.Get()).ToList();

            foreach (var item in bookings)
            {
                var bookingServiceDetails = (await bookingServiceDetailsRepository.Get(item.BookingId)).ToList();
                item.bookingServiceDetails = bookingServiceDetails;
                var bookingRoomDetails = (await bookingRoomDetailsRepository.Display(item.BookingId)).ToList();
                item.bookingRoomDetails = bookingRoomDetails;
            }

            var customers = await customerRepository.Get();

            var coupons = await couponRepository.GetAll();

            var data = (from b in bookings
                        join c in customers
                        on b.CustomerId equals c.CustomerId
                        join cp in coupons
                        on b.CouponId equals cp.CouponId into temp
                        from subtemp in temp.DefaultIfEmpty()
                        select new Booking
            {
                BookingId = b.BookingId,
                CreateDate = b.CreateDate,
                CheckinDate = b.CheckinDate,
                CheckoutDate = b.CheckoutDate,
                IsCanceled = b.IsCanceled,
                CustomerId = c.CustomerId,
                BookingCustomer = c,
                NumberofAdults = b.NumberofAdults,
                NumberofChildren = b.NumberofChildren,
                CouponId = b.CouponId,
                BookingCoupon = subtemp,
                bookingRoomDetails = b.bookingRoomDetails,
                bookingServiceDetails = b.bookingServiceDetails,
                RoomAmount = b.RoomAmount,
                ServiceAmount = b.ServiceAmount,
            });

            return(data);
        }
コード例 #5
0
 public List <Coupon> GetAll()
 {
     return(_couponRepository.GetAll());
 }
コード例 #6
0
 public async Task <IEnumerable <Coupon> > GetAll()
 {
     return(await couponRepository.GetAll());
 }