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

            this.Context.Entry(item).State = EntityState.Detached;
            return(item);
        }
        public async virtual Task Delete(
            int id)
        {
            VehCapability record = await this.GetById(id);

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

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

            await this.Context.SaveChangesAsync();
        }
Example #4
0
        public async void Create()
        {
            Mock <ILogger <VehCapabilityRepository> > loggerMoc = VehCapabilityRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = VehCapabilityRepositoryMoc.GetContext();
            var repository = new VehCapabilityRepository(loggerMoc.Object, context);

            var entity = new VehCapability();

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

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

            records.Count.Should().Be(2);
        }
Example #5
0
        public async void Get()
        {
            Mock <ILogger <VehCapabilityRepository> > loggerMoc = VehCapabilityRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = VehCapabilityRepositoryMoc.GetContext();
            var repository = new VehCapabilityRepository(loggerMoc.Object, context);

            VehCapability entity = new VehCapability();

            entity.SetProperties(default(int), "B");
            context.Set <VehCapability>().Add(entity);
            await context.SaveChangesAsync();

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

            record.Should().NotBeNull();
        }
Example #6
0
        public async void DeleteFound()
        {
            Mock <ILogger <VehCapabilityRepository> > loggerMoc = VehCapabilityRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = VehCapabilityRepositoryMoc.GetContext();
            var           repository     = new VehCapabilityRepository(loggerMoc.Object, context);
            VehCapability entity         = new VehCapability();

            entity.SetProperties(default(int), "B");
            context.Set <VehCapability>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Delete(entity.Id);

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

            records.Count.Should().Be(1);
        }
Example #7
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <VehCapabilityRepository> > loggerMoc = VehCapabilityRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = VehCapabilityRepositoryMoc.GetContext();
            var           repository     = new VehCapabilityRepository(loggerMoc.Object, context);
            VehCapability entity         = new VehCapability();

            entity.SetProperties(default(int), "B");
            context.Set <VehCapability>().Add(entity);
            await context.SaveChangesAsync();

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

            await repository.Update(entity);

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

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

            addressItem1.SetProperties(1, "A", "A", "A", "A", "A");
            this.Context.Addresses.Add(addressItem1);

            var callItem1 = new Call();

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

            var callAssignmentItem1 = new CallAssignment();

            callAssignmentItem1.SetProperties(1, 1, 1);
            this.Context.CallAssignments.Add(callAssignmentItem1);

            var callDispositionItem1 = new CallDisposition();

            callDispositionItem1.SetProperties(1, "A");
            this.Context.CallDispositions.Add(callDispositionItem1);

            var callPersonItem1 = new CallPerson();

            callPersonItem1.SetProperties(1, "A", 1, 1);
            this.Context.CallPersons.Add(callPersonItem1);

            var callStatusItem1 = new CallStatus();

            callStatusItem1.SetProperties(1, "A");
            this.Context.CallStatus.Add(callStatusItem1);

            var callTypeItem1 = new CallType();

            callTypeItem1.SetProperties(1, "A");
            this.Context.CallTypes.Add(callTypeItem1);

            var noteItem1 = new Note();

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

            var offCapabilityItem1 = new OffCapability();

            offCapabilityItem1.SetProperties(1, "A");
            this.Context.OffCapabilities.Add(offCapabilityItem1);

            var officerItem1 = new Officer();

            officerItem1.SetProperties(1, "A", "A", "A", "A", "A");
            this.Context.Officers.Add(officerItem1);

            var officerCapabilitiesItem1 = new OfficerCapabilities();

            officerCapabilitiesItem1.SetProperties(1, 1, 1);
            this.Context.OfficerCapabilities.Add(officerCapabilitiesItem1);

            var personItem1 = new Person();

            personItem1.SetProperties(1, "A", "A", "A", "A");
            this.Context.People.Add(personItem1);

            var personTypeItem1 = new PersonType();

            personTypeItem1.SetProperties(1, "A");
            this.Context.PersonTypes.Add(personTypeItem1);

            var unitItem1 = new Unit();

            unitItem1.SetProperties(1, "A");
            this.Context.Units.Add(unitItem1);

            var unitDispositionItem1 = new UnitDisposition();

            unitDispositionItem1.SetProperties(1, "A");
            this.Context.UnitDispositions.Add(unitDispositionItem1);

            var unitOfficerItem1 = new UnitOfficer();

            unitOfficerItem1.SetProperties(1, 1, 1);
            this.Context.UnitOfficers.Add(unitOfficerItem1);

            var vehCapabilityItem1 = new VehCapability();

            vehCapabilityItem1.SetProperties(1, "A");
            this.Context.VehCapabilities.Add(vehCapabilityItem1);

            var vehicleItem1 = new Vehicle();

            vehicleItem1.SetProperties(1, "A");
            this.Context.Vehicles.Add(vehicleItem1);

            var vehicleCapabilitiesItem1 = new VehicleCapabilities();

            vehicleCapabilitiesItem1.SetProperties(1, 1, 1);
            this.Context.VehicleCapabilities.Add(vehicleCapabilitiesItem1);

            var vehicleOfficerItem1 = new VehicleOfficer();

            vehicleOfficerItem1.SetProperties(1, 1, 1);
            this.Context.VehicleOfficers.Add(vehicleOfficerItem1);

            await this.Context.SaveChangesAsync();
        }
 public void SetVehicleCapabilityIdNavigation(VehCapability item)
 {
     this.VehicleCapabilityIdNavigation = item;
 }