示例#1
0
        public async virtual Task <TicketStatu> Create(TicketStatu item)
        {
            this.Context.Set <TicketStatu>().Add(item);
            await this.Context.SaveChangesAsync();

            this.Context.Entry(item).State = EntityState.Detached;
            return(item);
        }
示例#2
0
        public async void Create()
        {
            Mock <ILogger <TicketStatuRepository> > loggerMoc = TicketStatuRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TicketStatuRepositoryMoc.GetContext();
            var repository = new TicketStatuRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
示例#3
0
        public async void Get()
        {
            Mock <ILogger <TicketStatuRepository> > loggerMoc = TicketStatuRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TicketStatuRepositoryMoc.GetContext();
            var repository = new TicketStatuRepository(loggerMoc.Object, context);

            TicketStatu entity = new TicketStatu();

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

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

            record.Should().NotBeNull();
        }
示例#4
0
        public async virtual Task Delete(
            int id)
        {
            TicketStatu record = await this.GetById(id);

            if (record == null)
            {
                return;
            }
            else
            {
                this.Context.Set <TicketStatu>().Remove(record);
                await this.Context.SaveChangesAsync();
            }
        }
示例#5
0
        public async virtual Task Update(TicketStatu item)
        {
            var entity = this.Context.Set <TicketStatu>().Local.FirstOrDefault(x => x.Id == item.Id);

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

            await this.Context.SaveChangesAsync();
        }
示例#6
0
        public async void Delete()
        {
            Mock <ILogger <TicketStatuRepository> > loggerMoc = TicketStatuRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TicketStatuRepositoryMoc.GetContext();
            var         repository       = new TicketStatuRepository(loggerMoc.Object, context);
            TicketStatu entity           = new TicketStatu();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
示例#7
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <TicketStatuRepository> > loggerMoc = TicketStatuRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TicketStatuRepositoryMoc.GetContext();
            var         repository       = new TicketStatuRepository(loggerMoc.Object, context);
            TicketStatu entity           = new TicketStatu();

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

            await repository.Update(new TicketStatu());

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

            modifiedRecord.Should().NotBeNull();
        }
        public async void Migrate()
        {
            var adminItem1 = new Admin();

            adminItem1.SetProperties("A", "A", 1, "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("A", "A", 1, "A", "A");
            this.context.Customers.Add(customerItem1);

            var eventItem1 = new Event();

            eventItem1.SetProperties("A", "A", 1, DateTime.Parse("1/1/1987 12:00:00 AM"), "A", DateTime.Parse("1/1/1987 12:00:00 AM"), "A", 1, "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 ticketItem1 = new Ticket();

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

            var ticketStatuItem1 = new TicketStatu();

            ticketStatuItem1.SetProperties(1, "A");
            this.context.TicketStatus.Add(ticketStatuItem1);

            var transactionItem1 = new Transaction();

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

            var transactionStatuItem1 = new TransactionStatu();

            transactionStatuItem1.SetProperties(1, "A");
            this.context.TransactionStatus.Add(transactionStatuItem1);

            var venueItem1 = new Venue();

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

            await this.context.SaveChangesAsync();
        }