public async virtual Task <TransactionStatu> Create(TransactionStatu item)
        {
            this.Context.Set <TransactionStatu>().Add(item);
            await this.Context.SaveChangesAsync();

            this.Context.Entry(item).State = EntityState.Detached;
            return(item);
        }
Exemplo n.º 2
0
        public async void Create()
        {
            Mock <ILogger <TransactionStatuRepository> > loggerMoc = TransactionStatuRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TransactionStatuRepositoryMoc.GetContext();
            var repository = new TransactionStatuRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
Exemplo n.º 3
0
        public async void Get()
        {
            Mock <ILogger <TransactionStatuRepository> > loggerMoc = TransactionStatuRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TransactionStatuRepositoryMoc.GetContext();
            var repository = new TransactionStatuRepository(loggerMoc.Object, context);

            TransactionStatu entity = new TransactionStatu();

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

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

            record.Should().NotBeNull();
        }
        public async virtual Task Delete(
            int id)
        {
            TransactionStatu record = await this.GetById(id);

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

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

            await this.Context.SaveChangesAsync();
        }
Exemplo n.º 6
0
        public async void Delete()
        {
            Mock <ILogger <TransactionStatuRepository> > loggerMoc = TransactionStatuRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TransactionStatuRepositoryMoc.GetContext();
            var repository          = new TransactionStatuRepository(loggerMoc.Object, context);
            TransactionStatu entity = new TransactionStatu();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
Exemplo n.º 7
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <TransactionStatuRepository> > loggerMoc = TransactionStatuRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TransactionStatuRepositoryMoc.GetContext();
            var repository          = new TransactionStatuRepository(loggerMoc.Object, context);
            TransactionStatu entity = new TransactionStatu();

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

            await repository.Update(new TransactionStatu());

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

            modifiedRecord.Should().NotBeNull();
        }
Exemplo n.º 8
0
        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();
        }