Ejemplo n.º 1
0
        public async virtual Task <SaleTickets> Create(SaleTickets item)
        {
            this.Context.Set <SaleTickets>().Add(item);
            await this.Context.SaveChangesAsync();

            this.Context.Entry(item).State = EntityState.Detached;
            return(item);
        }
        public async void Create()
        {
            Mock <ILogger <SaleTicketsRepository> > loggerMoc = SaleTicketsRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SaleTicketsRepositoryMoc.GetContext();
            var repository = new SaleTicketsRepository(loggerMoc.Object, context);

            var entity = new SaleTickets();
            await repository.Create(entity);

            var record = await context.Set <SaleTickets>().FirstOrDefaultAsync();

            record.Should().NotBeNull();
        }
Ejemplo n.º 3
0
        public async virtual Task Delete(
            int id)
        {
            SaleTickets record = await this.GetById(id);

            if (record == null)
            {
                return;
            }
            else
            {
                this.Context.Set <SaleTickets>().Remove(record);
                await this.Context.SaveChangesAsync();
            }
        }
Ejemplo n.º 4
0
        public async virtual Task Update(SaleTickets item)
        {
            var entity = this.Context.Set <SaleTickets>().Local.FirstOrDefault(x => x.Id == item.Id);

            if (entity == null)
            {
                this.Context.Set <SaleTickets>().Attach(item);
            }
            else
            {
                this.Context.Entry(entity).CurrentValues.SetValues(item);
            }

            await this.Context.SaveChangesAsync();
        }
        public async void Get()
        {
            Mock <ILogger <SaleTicketsRepository> > loggerMoc = SaleTicketsRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SaleTicketsRepositoryMoc.GetContext();
            var repository = new SaleTicketsRepository(loggerMoc.Object, context);

            SaleTickets entity = new SaleTickets();

            context.Set <SaleTickets>().Add(entity);
            await context.SaveChangesAsync();

            var record = await repository.Get(entity.Id);

            record.Should().NotBeNull();
        }
        public async void Create()
        {
            Mock <ILogger <SaleTicketsRepository> > loggerMoc = SaleTicketsRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SaleTicketsRepositoryMoc.GetContext();
            var repository = new SaleTicketsRepository(loggerMoc.Object, context);

            var entity = new SaleTickets();

            entity.SetProperties(default(int), 1, 1);
            await repository.Create(entity);

            var records = await context.Set <SaleTickets>().ToListAsync();

            records.Count.Should().Be(2);
        }
        public async void Delete()
        {
            Mock <ILogger <SaleTicketsRepository> > loggerMoc = SaleTicketsRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SaleTicketsRepositoryMoc.GetContext();
            var         repository       = new SaleTicketsRepository(loggerMoc.Object, context);
            SaleTickets entity           = new SaleTickets();

            context.Set <SaleTickets>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Delete(entity.Id);

            SaleTickets modifiedRecord = await context.Set <SaleTickets>().FirstOrDefaultAsync();

            modifiedRecord.Should().BeNull();
        }
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <SaleTicketsRepository> > loggerMoc = SaleTicketsRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SaleTicketsRepositoryMoc.GetContext();
            var         repository       = new SaleTicketsRepository(loggerMoc.Object, context);
            SaleTickets entity           = new SaleTickets();

            context.Set <SaleTickets>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Update(new SaleTickets());

            var modifiedRecord = context.Set <SaleTickets>().FirstOrDefaultAsync();

            modifiedRecord.Should().NotBeNull();
        }
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <SaleTicketsRepository> > loggerMoc = SaleTicketsRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SaleTicketsRepositoryMoc.GetContext();
            var         repository       = new SaleTicketsRepository(loggerMoc.Object, context);
            SaleTickets entity           = new SaleTickets();

            entity.SetProperties(default(int), 1, 1);
            context.Set <SaleTickets>().Add(entity);
            await context.SaveChangesAsync();

            context.Entry(entity).State = EntityState.Detached;

            await repository.Update(entity);

            var records = await context.Set <SaleTickets>().ToListAsync();

            records.Count.Should().Be(2);
        }
        public virtual async Task Migrate()
        {
            var adminItem1 = new Admin();

            adminItem1.SetProperties(1, "A", "A", "A", "A", "A", "A");
            this.Context.Admins.Add(adminItem1);

            var cityItem1 = new City();

            cityItem1.SetProperties(1, "A", 1);
            this.Context.Cities.Add(cityItem1);

            var countryItem1 = new Country();

            countryItem1.SetProperties(1, "A");
            this.Context.Countries.Add(countryItem1);

            var customerItem1 = new Customer();

            customerItem1.SetProperties(1, "A", "A", "A", "A");
            this.Context.Customers.Add(customerItem1);

            var eventItem1 = new Event();

            eventItem1.SetProperties(1, "A", "A", 1, DateTime.Parse("1/1/1987 12:00:00 AM"), "A", DateTime.Parse("1/1/1987 12:00:00 AM"), "A", "A", DateTime.Parse("1/1/1987 12:00:00 AM"), "A");
            this.Context.Events.Add(eventItem1);

            var provinceItem1 = new Province();

            provinceItem1.SetProperties(1, 1, "A");
            this.Context.Provinces.Add(provinceItem1);

            var saleItem1 = new Sale();

            saleItem1.SetProperties(1, "A", "A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1);
            this.Context.Sales.Add(saleItem1);

            var saleTicketsItem1 = new SaleTickets();

            saleTicketsItem1.SetProperties(1, 1, 1);
            this.Context.SaleTickets.Add(saleTicketsItem1);

            var ticketItem1 = new Ticket();

            ticketItem1.SetProperties(1, "A", 1);
            this.Context.Tickets.Add(ticketItem1);

            var ticketStatusItem1 = new TicketStatus();

            ticketStatusItem1.SetProperties(1, "A");
            this.Context.TicketStatus.Add(ticketStatusItem1);

            var transactionItem1 = new Transaction();

            transactionItem1.SetProperties(1, 1m, "A", 1);
            this.Context.Transactions.Add(transactionItem1);

            var transactionStatusItem1 = new TransactionStatus();

            transactionStatusItem1.SetProperties(1, "A");
            this.Context.TransactionStatus.Add(transactionStatusItem1);

            var venueItem1 = new Venue();

            venueItem1.SetProperties(1, "A", "A", 1, "A", "A", "A", "A", 1, "A");
            this.Context.Venues.Add(venueItem1);

            await this.Context.SaveChangesAsync();
        }