Beispiel #1
0
        public void AddOrUpdateLoadTests(AddOrUpdateLoadTestsValidationResult addOrUpdateLoadTestsValidationResult)
        {
            LoadTestingContext context = new LoadTestingContext();

            if (addOrUpdateLoadTestsValidationResult.ValidationComplete)
            {
                if (addOrUpdateLoadTestsValidationResult.ToBeInserted.Any())
                {
                    foreach (LoadTest toBeInserted in addOrUpdateLoadTestsValidationResult.ToBeInserted)
                    {
                        context.Entry <LoadTest>(toBeInserted).State = System.Data.Entity.EntityState.Added;
                    }
                }

                if (addOrUpdateLoadTestsValidationResult.ToBeUpdated.Any())
                {
                    foreach (LoadTest toBeUpdated in addOrUpdateLoadTestsValidationResult.ToBeUpdated)
                    {
                        context.Entry <LoadTest>(toBeUpdated).State = System.Data.Entity.EntityState.Modified;
                    }
                }
            }
            else
            {
                throw new InvalidOperationException("Validation is not complete. You have to call the AddOrUpdateLoadTests method of the Timetable class first.");
            }

            context.SaveChanges();
        }
Beispiel #2
0
        public void DeleteById(Guid guid)
        {
            LoadTestingContext context  = new LoadTestingContext();
            LoadTest           loadTest = context.LoadTests.FirstOrDefault(l => l.Id == guid);

            if (loadTest == null)
            {
                throw new ArgumentException(String.Format("There's no load test by ID{0}", guid));
            }
            context.Entry <LoadTest>(loadTest).State = System.Data.Entity.EntityState.Deleted;
            context.SaveChanges();
        }
Beispiel #3
0
        public void DeleteById(Guid guid)
        {
            LoadTestingContext context  = new LoadTestingContext(_options);
            Loadtest           loadtest = (from l in context.Loadtests where l.Id == guid select l).FirstOrDefault();

            if (loadtest == null)
            {
                throw new ArgumentException(string.Format("There's no load test by ID {0}", guid));
            }
            context.Entry <Loadtest>(loadtest).State = EntityState.Deleted;
            context.SaveChanges();
        }
Beispiel #4
0
        public void DeleteById(Guid guid)
        {
            var context  = new LoadTestingContext();
            var loadtest = (from l in context.Loadtests
                            where l.Id == guid
                            select l).FirstOrDefault();

            if (loadtest == null)
            {
                throw new ArgumentException($"There's no load test by ID {guid}");
            }

            context.Entry(loadtest).State = EntityState.Deleted;
            context.SaveChanges();
        }