Пример #1
0
        public int SetTMEventSeatState(int tmeventSeatId, SeatState state)
        {
            TMEventSeatDto tmeventSeatDto = _tmeventSeatService.GetTMEventSeat(tmeventSeatId);

            tmeventSeatDto.State = state;
            return(_tmeventSeatService.UpdateTMEventSeat(tmeventSeatDto));
        }
Пример #2
0
        public PurchaseStatus ReturnTicket(string userId, int tmeventSeatId)
        {
            TMEventSeatDto seat       = _tmeventSeatService.GetTMEventSeat(tmeventSeatId);
            TMEventAreaDto area       = _tmeventAreaService.GetTMEventArea(seat.TMEventAreaId);
            var            tmeventObj = _tmeventService.GetTMEvent(area.TMEventId);

            if (tmeventObj.StartEvent > DateTime.Now)
            {
                _tmeventAreaService.SetTMEventSeatState(tmeventSeatId, SeatState.Free);

                var ph = _purchaseHistoryRepository.GetAll()
                         .Where(p => p.UserId.Equals(userId, StringComparison.OrdinalIgnoreCase))
                         .FirstOrDefault(p => p.TMEventSeatId == tmeventSeatId);

                if (ph != null)
                {
                    _purchaseHistoryRepository.Remove(ph.Id);

                    _userService.TopUpBalance(userId, area.Price);
                }

                return(PurchaseStatus.ReturnTicketSucsess);
            }

            return(PurchaseStatus.ReturnTicketFailWithPastEvent);
        }
Пример #3
0
 private static TMEventSeat ConvertToEntity(TMEventSeatDto obj)
 {
     return(new TMEventSeat
     {
         Id = obj.Id,
         Number = obj.Number,
         Row = obj.Row,
         State = (int)obj.State,
         TMEventAreaId = obj.TMEventAreaId,
     });
 }
Пример #4
0
        public List <PurchaseHistoryDto> GetPurchaseHistory(string userId)
        {
            List <PurchaseHistory> ph =
                _purchaseHistoryRepository.GetAll().Where(p => p.UserId == userId).ToList();

            var phdto = new List <PurchaseHistoryDto>();

            foreach (var item in ph)
            {
                TMEventSeatDto seat = _tmeventSeatService.GetTMEventSeat(item.TMEventSeatId);
                TMEventAreaDto area = _tmeventAreaService.GetTMEventArea(seat.TMEventAreaId);

                phdto.Add(new PurchaseHistoryDto
                {
                    SeatObj     = seat,
                    BookingDate = item.BookingDate,
                    AreaPrice   = area.Price,
                    TMEventObj  = _tmeventService.GetTMEvent(area.TMEventId),
                });
            }

            return(phdto);
        }
Пример #5
0
 public TMEventSeatDto CreateTMEventSeat(TMEventSeatDto obj)
 {
     return(ConvertToDto(_tmeventSeatRepository.Create(ConvertToEntity(obj))));
 }
Пример #6
0
        public int UpdateTMEventSeat(TMEventSeatDto obj)
        {
            _tmeventSeatRepository.Update(ConvertToEntity(obj));

            return(1);
        }