Пример #1
0
        public async Task <bool> CreatePlace(Place place)
        {
            await _dataContext.Places.AddAsync(place);

            var created = await _dataContext.SaveChangesAsync();

            return(created > 0);
        }
Пример #2
0
        public async Task <bool> AddCustomer(Customer customer)
        {
            await _context.AddAsync(customer);

            if (await _context.SaveChangesAsync() > 0)
            {
                return(true);
            }
            return(false);
        }
Пример #3
0
        public async Task <bool> AddReservation(Reservation reservation)
        {
            await _context.AddAsync(reservation);

            if (await _context.SaveChangesAsync() > 0)
            {
                return(true);
            }
            return(false);
        }
Пример #4
0
        public async Task <bool> AddPricePerPeople(PricePerPeople pricePerPeople)
        {
            await _context.AddAsync(pricePerPeople);

            if (await _context.SaveChangesAsync() > 0)
            {
                return(true);
            }
            return(false);
        }
Пример #5
0
        public async Task <bool> AddObjectForRent(ObjectForRent objectForRent)
        {
            await _context.AddAsync(objectForRent);

            if (await _context.SaveChangesAsync() > 0)
            {
                return(true);
            }
            return(false);
        }
Пример #6
0
        public async Task <bool> CreateEvent(Event eventCreate)
        {
            var places = _dataContext.Places.Where(t => t.PlaceId == eventCreate.PlaceId).FirstOrDefault();

            if (eventCreate.PlaceId < 1 || places == null)
            {
                throw new NullReferenceException("Selected Place doesn't exist");
            }

            var types = _dataContext.EventTypes.Where(et => et.TypeId == eventCreate.TypeId).FirstOrDefault();

            if (eventCreate.TypeId < 1 || types == null)
            {
                throw new NullReferenceException("Selected Type doesn't exist");
            }

            await _dataContext.Events.AddAsync(eventCreate);

            var created = await _dataContext.SaveChangesAsync();

            return(created > 0);
        }
Пример #7
0
        public async Task <bool> CreateSeat(Seat seat)
        {
            var types = _dataContext.SeatTypes.Where(st => st.TypeId == seat.TypeId).FirstOrDefault();

            if (types == null)
            {
                throw new NullReferenceException("Selected type doesn't exist");
            }

            var places = _dataContext.Places.Where(p => p.PlaceId == seat.PlaceId).FirstOrDefault();

            if (places == null)
            {
                throw new NullReferenceException("Selected place doesn't exist");
            }

            await _dataContext.AddAsync(seat);

            var created = await _dataContext.SaveChangesAsync();

            return(created > 0);
        }
Пример #8
0
        public async Task <bool> CreateTicket(Ticket ticket)
        {
            var createTicket = await _dataContext.SeatStatuses.FirstOrDefaultAsync(ss => ss.StatusId == ticket.StatusId);

            if (createTicket == null)
            {
                throw new NullReferenceException("Selected seat status doesn't exist");
            }

            await _dataContext.AddAsync(ticket);

            var created = await _dataContext.SaveChangesAsync();

            return(created > 0);
        }