public void ProgramRepositoryWhenEmptyFirstLineReturnsNull()
        {
            var sut         = new ProgramRepository();
            var currentLine = sut.GetFirstLine();

            Assert.IsNull(currentLine);
        }
Ejemplo n.º 2
0
        public RequestViewModel(RequestClass requestmodel, RequestRepository requestRepository, ProgramRepository programRepository, BatteryRepository batteryRepository)     //RequestView需要
        {
            if (requestmodel == null)
            {
                throw new ArgumentNullException("Requestmodel");
            }

            if (requestRepository == null)
            {
                throw new ArgumentNullException("RequestRepository");
            }

            if (programRepository == null)
            {
                throw new ArgumentNullException("programRepository");
            }

            if (batteryRepository == null)
            {
                throw new ArgumentNullException("batteryRepository");
            }

            _request           = requestmodel;
            _requestRepository = requestRepository;
            _programRepository = programRepository;
            _batteryRepository = batteryRepository;
        }
        public void ProgramRepositoryCanDeleteLineRange(int start, int end, int[] expected)
        {
            var sut = new ProgramRepository();

            sut.SetProgramLine(new ProgramLine(30, new List <IToken> {
                new Token("X")
            }));
            sut.SetProgramLine(new ProgramLine(10, new List <IToken> {
                new Token("X")
            }));
            sut.SetProgramLine(new ProgramLine(20, new List <IToken> {
                new Token("X")
            }));
            sut.SetProgramLine(new ProgramLine(50, new List <IToken> {
                new Token("X")
            }));
            sut.SetProgramLine(new ProgramLine(40, new List <IToken> {
                new Token("X")
            }));

            sut.DeleteProgramLines(start, end);

            var lineNumbers = new List <int>();
            var currentLine = sut.GetFirstLine();

            do
            {
                lineNumbers.Add(currentLine.LineNumber.Value);
                currentLine = sut.GetNextLine(currentLine.LineNumber.Value);
            }while (currentLine != null);

            CollectionAssert.AreEqual(expected, lineNumbers.ToArray());
        }
Ejemplo n.º 4
0
        public ICollection <ProgramDTO> GetUsersPrograms(ProgramDTO newProgram, String userName)
        {
            ActionResponse response = new ActionResponse();

            ProgramRepository repository = RepositoriesFactory.CreateRepository <ProgramRepository, Program>();

            int UserId = GetCurrentUser().UserId;

            ICollection <Program> wantedPrograms;

            if (GetCurrentUser().Permission == (int)Enums.PermissionsType.Admin)
            {
                wantedPrograms = repository.GetALL();
            }
            else
            {
                wantedPrograms =
                    repository.Query().Where(CurrProgram => CurrProgram.UserPrograms.Any(currUser => currUser.UserId == UserId)).ToList();
            }


            ICollection <ProgramDTO> ProgramDrills =
                wantedPrograms.Select <Program, ProgramDTO>(currProgram => ConvertEntityTODTO(currProgram)).ToList();

            return(ProgramDrills);
        }
        public void ProgramRepositoryCanGetLineResetsCurrentToken()
        {
            var sut = new ProgramRepository();

            sut.SetProgramLine(new ProgramLine(10, new List <IToken> {
                new Token("X")
            }));
            sut.SetProgramLine(new ProgramLine(20, new List <IToken> {
                new Token("X")
            }));
            sut.SetProgramLine(new ProgramLine(40, new List <IToken> {
                new Token("X")
            }));

            var line20 = sut.GetLine(20);

            line20.NextToken();

            Assert.IsTrue(line20.EndOfLine);

            var newLine20 = sut.GetLine(20);

            Assert.IsFalse(newLine20.EndOfLine);
            Assert.AreEqual(0, newLine20.CurrentToken);
            Assert.AreNotEqual(line20, newLine20);
        }
        public void ProgramRepositorySortsLinesIntoOrder()
        {
            var sut = new ProgramRepository();

            sut.SetProgramLine(new ProgramLine(30, new List <IToken> {
                new Token("X")
            }));
            sut.SetProgramLine(new ProgramLine(10, new List <IToken> {
                new Token("X")
            }));
            sut.SetProgramLine(new ProgramLine(20, new List <IToken> {
                new Token("X")
            }));
            sut.SetProgramLine(new ProgramLine(50, new List <IToken> {
                new Token("X")
            }));
            sut.SetProgramLine(new ProgramLine(40, new List <IToken> {
                new Token("X")
            }));

            var lineNumbers = new List <int?>();
            var currentLine = sut.GetFirstLine();

            do
            {
                lineNumbers.Add(currentLine.LineNumber);
                currentLine = sut.GetNextLine(currentLine.LineNumber.Value);
            }while (currentLine != null);

            CollectionAssert.AreEqual(new List <int?> {
                10, 20, 30, 40, 50
            }, lineNumbers);
        }
        private IProgramsUnitOfWork GetUnit(List <ProgramUpdatePackageInfo> list, List <TelimenaPackageInfo> toolkitPackages = null)
        {
            UpdatePackageRepository  pkgRepo    = new UpdatePackageRepository(this.Context, new AssemblyStreamVersionReader());
            ProgramRepository        prgRepo    = new ProgramRepository(this.Context);
            ProgramPackageRepository prgPkgRepo = new ProgramPackageRepository(this.Context, new AssemblyStreamVersionReader());

            prgPkgRepo.Add(new ProgramPackageInfo("Prg.zip", this.Prg_1, "1.0.0.0", 2222, "1.0.0.0"));
            prgRepo.Add(new Program("prg", this.Program1Key)
            {
                Id = this.Prg_1
            });

            Mock <IAssemblyStreamVersionReader> reader = TestingUtilities.GetMockVersionReader();

            this.AddToolkits(reader.Object, toolkitPackages);

            foreach (ProgramUpdatePackageInfo programUpdatePackageInfo in list)
            {
                pkgRepo.Add(programUpdatePackageInfo);
            }

            this.Context.SaveChanges();



            ProgramsUnitOfWork unit = new ProgramsUnitOfWork(this.Context, reader.Object);

            return(unit);
        }
Ejemplo n.º 8
0
        public void Edit(ProgramModel viewModel)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException("viewModel");
            }
            Program toUpdate = ProgramRepository.Items.Include(s => s.ServiceOfferings).Include(s => s.Schools).SingleOrDefault(p => p.Id == viewModel.Id);

            if (toUpdate == null || !toUpdate.IsActive)
            {
                throw new EntityNotFoundException("Could not find Program with specified Id.");
            }
            var currentMappings = ServiceOfferingRepository.Items.
                                  Include(c => c.ServiceType).
                                  Include(c => c.Provider).
                                  Include("StudentAssignedOfferings").
                                  Where(s => s.ProgramId == viewModel.Id).ToList();
            var newMappings = GenerateServiceOfferingMappings(viewModel, toUpdate);

            UpdateSchools(viewModel, toUpdate);
            DeactivateServiceOfferings(currentMappings, newMappings);
            ActivateServiceOfferings(currentMappings, newMappings);
            viewModel.CopyTo(toUpdate);
            ProgramRepository.Update(toUpdate);
            RepositoryContainer.Save();
        }
Ejemplo n.º 9
0
        public void Create(ProgramModel viewModel)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException("viewModel");
            }
            Program item = ProgramRepository.Items.SingleOrDefault(p => p.Name == viewModel.Name && !p.IsActive);

            if (item == null)
            {
                item = new Program();
                ProgramRepository.Add(item);
            }
            viewModel.Id  = item.Id;
            item.IsActive = true;
            viewModel.CopyTo(item);
            UpdateSchools(viewModel, item);
            var mappings = GenerateServiceOfferingMappings(viewModel, item);

            foreach (var mapping in mappings)
            {
                if (!ServiceOfferingRepository.Items.Where(s => s.ProgramId == mapping.ProgramId && s.ProviderId == mapping.ProviderId && s.ServiceTypeId == mapping.ServiceTypeId).Any())
                {
                    item.ServiceOfferings.Add(mapping);
                    ServiceOfferingRepository.Add(mapping);
                }
            }
            RepositoryContainer.Save();
        }
Ejemplo n.º 10
0
        public ActionResponse UpdateProgram(ProgramDTO program)
        {
            ActionResponse response = ValidateProgram(program, true);

            if (response != null)
            {
                return(response);
            }

            response = CanUserEditProgram(program.Id);

            if (response != null)
            {
                return(response);
            }

            Program programForUpdate = ConvertDTOToEntity(program);

            ProgramRepository programRepository = RepositoriesFactory.CreateRepository <ProgramRepository, Program>();

            Program existingProgram = programRepository.Get(programForUpdate.ProgramId);

            existingProgram.ProgramName = programForUpdate.ProgramName;

            foreach (ProgramDrill currDrill in programForUpdate.ProgramDrills)
            {
                ProgramDrill existingProgramDrill =
                    existingProgram.ProgramDrills.FirstOrDefault(currProgramDrill => currProgramDrill.Id == currDrill.Id);
                if (existingProgramDrill == null)
                {
                    existingProgram.ProgramDrills.Add(currDrill);
                }
                else
                {
                    foreach (Set currSet in currDrill.Sets)
                    {
                        Set existingSet =
                            existingProgramDrill.Sets.FirstOrDefault(currExistingSet => currExistingSet.SetId == currSet.SetId);

                        if (existingSet == null)
                        {
                            existingProgramDrill.Sets.Add(currSet);
                        }
                        else
                        {
                            existingSet.Repetitions = currSet.Repetitions;
                            existingSet.Weight      = currSet.Weight;
                            existingSet.Repetitions = currSet.Repetitions;
                        }
                    }
                }
            }

            programRepository.Update(existingProgram);
            return(new ActionResponse()
            {
                CompletedSuccessfully = true
            });
        }
        public void TestGetProgramFromRepository()
        {
            int programID = 44559;

            IProgramRepository programRepository = new ProgramRepository();
            Program            program           = programRepository.GetProgram(programID);

            Assert.IsNotNull(program);
        }
        public void BindRepeator()
        {
            ProgramRepository objProgramRepository = new ProgramRepository();
            List <Program>    program = new List <Program>();

            program = objProgramRepository.GetPrivateProgram().ToList();
            PublicRepeator.DataSource = program;
            PublicRepeator.DataBind();
        }
Ejemplo n.º 13
0
 public TicketService(TicketListAllQuery ticketListAllQuery, TicketRepository ticketRepository, ProgramRepository programRepository, DiscountRepository discountRepository, CustomerRepository customerRepository, CompanyRepository companyRepository)
 {
     this.ticketListAllQuery = ticketListAllQuery;
     this.companyRepository  = companyRepository;
     this.customerRepository = customerRepository;
     this.ticketRepository   = ticketRepository;
     this.programRepository  = programRepository;
     this.discountRepository = discountRepository;
 }
Ejemplo n.º 14
0
 public UnitOfWork(LibarysystemDBcontext libarysystemDBcontext)
 {
     _context   = libarysystemDBcontext;
     activities = new ActivitiesRepository(_context);
     alumnus    = new AlumnusRepository(_context);
     program    = new ProgramRepository(_context);
     section    = new SectionRepository(_context);
     employee   = new EmployeeRepository(_context);
     person     = new PersonRepository(_context);
 }
Ejemplo n.º 15
0
 public UnitOfWork(DatabaseContext databaseContext)
 {
     _context                      = databaseContext;
     AlumnRepository               = new AlumnRepository(_context);
     PersonalRepository            = new PersonalRepository(_context);
     AktivitetRepository           = new AktivitetRepository(_context);
     KompetensRepository           = new KompetensRepository(_context);
     ProgramRepository             = new ProgramRepository(_context);
     InformationsutskickRepository = new InformationsutskickRepository(_context);
 }
Ejemplo n.º 16
0
        public async Task Should_Get_Entity_When_ReadEntityAsync()
        {
            var programId = Guid.NewGuid();

            var mockedContextMock = new Mock <IDynamoDBContext>();

            mockedContextMock.Setup(ctx =>
                                    ctx.LoadAsync <ProgramEntity>(It.IsAny <Guid>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new ProgramEntity()
            {
                Id            = programId,
                Name          = "Origin",
                Introduction  = "Origin",
                PerformerIds  = new[] { Guid.NewGuid() },
                IsDeleted     = false,
                CreatedAt     = DateTime.Today.AddDays(-2),
                UpdatedAt     = DateTime.Today.AddDays(-1),
                VersionNumber = 2
            });
            mockedContextMock.Setup(ctx =>
                                    ctx.SaveAsync(It.IsAny <ProgramEntity>(), It.IsAny <CancellationToken>()))
            .Verifiable();
            var mockedRepository = new ProgramRepository(mockedContextMock.Object);
            var entity           = await mockedRepository.UpdateEntityAsync(Guid.NewGuid(), new ProgramEntity()
            {
                Id            = Guid.NewGuid(),
                Name          = "Mocked",
                Introduction  = "Mocked",
                IsDeleted     = false,
                PerformerIds  = new[] { Guid.NewGuid(), Guid.NewGuid() },
                CreatedAt     = DateTime.Today.AddDays(-1),
                UpdatedAt     = DateTime.Today,
                VersionNumber = 2
            });

            mockedContextMock.Verify();
            Assert.NotNull(entity);
            Assert.Equal(programId, entity.Id);
            Assert.Equal("Mocked", entity.Name);
            Assert.Equal("Mocked", entity.Introduction);
            Assert.Equal(DateTime.Today.AddDays(-1), entity.CreatedAt);
            Assert.InRange(entity.UpdatedAt, DateTime.Today.ToUniversalTime(), DateTime.Now);
            Assert.Equal(2, entity.VersionNumber);
            Assert.NotNull(entity.PerformerIds);
            Assert.NotEmpty(entity.PerformerIds !);

            var entity2 = await mockedRepository.DeleteEntityAsync(programId, false);

            mockedContextMock.Verify();
            Assert.NotNull(entity2);
            Assert.True(entity2.IsDeleted);
            Assert.InRange(entity.UpdatedAt, DateTime.Today.ToUniversalTime(), DateTime.Now);
        }
Ejemplo n.º 17
0
        public void Should_GetNextId_When_HaveProgramRepository()
        {
            var mockedContext = new Mock <IDynamoDBContext>();
            var programRepo   = new ProgramRepository(mockedContext.Object);
            var nextId        = typeof(ProgramRepository).GetMethod(
                "NextKey",
                BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.NonPublic
                );

            Assert.NotNull(nextId);
            Assert.IsType <Guid>(nextId?.Invoke(programRepo, new object[0]));
        }
Ejemplo n.º 18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ProgramRepository objProgramRepository = new ProgramRepository();

            if (HttpUtility.UrlDecode(Request.QueryString["id"]) != null)
            {
                List <Program> program = new List <Program>();
                program.Add(objProgramRepository.GetByProgramID(Convert.ToInt32(HttpUtility.UrlDecode(Request.QueryString["id"]))));
                RepeaterProgram.DataSource = program;
                RepeaterProgram.DataBind();
            }
        }
Ejemplo n.º 19
0
        public ProgramsService(
            ProgramRepository programRepository,
            StudyYearRepository studyYearRepository,
            LocaleInfo locale)
        {
            this.programRepository = programRepository ??
                                     throw new ArgumentNullException(nameof(programRepository));

            this.studyYearRepository = studyYearRepository ??
                                       throw new ArgumentNullException(nameof(studyYearRepository));

            language = locale.Language;
        }
Ejemplo n.º 20
0
        public ICollection <ProgramDTO> GetAllPrograms(ProgramDTO newProgram)
        {
            ActionResponse response = new ActionResponse();

            ProgramRepository repository = RepositoriesFactory.CreateRepository <ProgramRepository, Program>();

            ICollection <Program> wantedPrograms = repository.GetALL();

            ICollection <ProgramDTO> ProgramDrills = wantedPrograms
                                                     .Select <Program, ProgramDTO>(currProgram => ConvertEntityTODTO(currProgram)).ToList();

            return(ProgramDrills);
        }
Ejemplo n.º 21
0
        public void _08_Challenge_GoodDriver_ShouldBeCorrectCount()
        {
            //Arrange
            ProgramRepository _programRepo = new ProgramRepository();
            KomodoProgram     GoodDriver   = new KomodoProgram();

            _programRepo.GoodDriver(answer);

            //Act



            //Assert
        }
        public void ProgramRepositoryGetLineThrowsOnInvalidLineNumber(int lineNumber, bool throwsException)
        {
            var sut = new ProgramRepository();

            sut.SetProgramLine(new ProgramLine(10, new List <IToken> {
                new Token("X")
            }));
            sut.SetProgramLine(new ProgramLine(20, new List <IToken> {
                new Token("X")
            }));
            sut.SetProgramLine(new ProgramLine(40, new List <IToken> {
                new Token("X")
            }));

            Test.Throws <UndefinedStatementException>(() => sut.GetLine(lineNumber), throwsException);
        }
Ejemplo n.º 23
0
        public void SetUp()
        {
            _ministryPlatformService = new Mock <IMinistryPlatformService>();
            _authService             = new Mock <IAuthenticationRepository>();
            _configWrapper           = new Mock <IConfigurationWrapper>();

            _configWrapper.Setup(m => m.GetEnvironmentVarAsString("API_USER")).Returns("uid");
            _configWrapper.Setup(m => m.GetEnvironmentVarAsString("API_PASSWORD")).Returns("pwd");
            _configWrapper.Setup(m => m.GetConfigIntValue("OnlineGivingProgramsPageViewId")).Returns(OnlineGivingProgramsPageViewId);
            _configWrapper.Setup(m => m.GetConfigIntValue("Programs")).Returns(ProgramsPageId);
            _authService.Setup(m => m.Authenticate(It.IsAny <string>(), It.IsAny <string>())).Returns(new Dictionary <string, object> {
                { "token", "ABC" }, { "exp", "123" }
            });

            AutoMapperConfig.RegisterMappings();

            _fixture = new ProgramRepository(_ministryPlatformService.Object, _authService.Object, _configWrapper.Object);
        }
Ejemplo n.º 24
0
        public ActionResponse DeleteProgram(int programId)
        {
            ActionResponse response = CanUserEditProgram(programId);

            if (response != null)
            {
                return(response);
            }

            ProgramRepository programRepository = RepositoriesFactory.CreateRepository <ProgramRepository, Program>();

            programRepository.Delete(programId);

            return(new ActionResponse()
            {
                CompletedSuccessfully = true
            });
        }
Ejemplo n.º 25
0
        public EntityService()
        {
            weekDayRepository     = new WeekDayRepository();
            roomLectureRepository = new RoomLectureRepository();
            roomRepository        = new RoomRepository();

            lectureRepository         = new LectureRepository();
            parentRepository          = new ParentRepository();
            postponedLessonRepository = new PostponedLessonRepository();
            programRepository         = new ProgramRepository();
            recievedPaymentRepository = new RecievedPaymentRepository();

            studentRepository        = new StudentRepository();
            teacherLectureRepository = new TeacherLectureRepository();
            teacherPaymentRepository = new TeacherPaymentRepository();
            teacherRepository        = new TeacherRepository();
            userRepository           = new UserRepository();
        }
Ejemplo n.º 26
0
        public void NoPackagesAvailable_ShouldNotThrowErrors()
        {
            ProgramRepository prgRepo = new ProgramRepository(this.Context);

            prgRepo.Add(new Program("prg", this.Program1Key)
            {
                Id = this.Prg_1
            });
            this.Context.SaveChanges();
            IProgramsUnitOfWork unit = new ProgramsUnitOfWork(this.Context, TestingUtilities.GetMockVersionReader().Object);

            ProgramsController sut     = new ProgramsController(unit, new Mock <IFileSaver>().Object, new Mock <IFileRetriever>().Object);
            UpdateRequest      request = new UpdateRequest(this.Program1Key, new VersionData("", "1.2.0.0"), this.User1Guid, false, "0.7.0.0", "1.0.0.0");

            UpdateResponse result = sut.UpdateCheck(request).GetAwaiter().GetResult();

            Assert.AreEqual(0, result.UpdatePackages.Count());
            Assert.IsNull(result.Exception);
        }
Ejemplo n.º 27
0
 public RouteService(RouteStationForBetweenQuery routeStationForBetweenQuery, CompanyRouteListQuery companyRouteListQuery, CompanyRepository companyRepository, RouteListAllQuery routeListAllQuery, EmptyProgramsListQuery emptyProgramsListQuery, SeatRepository seatRepository, SeatListQuery seatListQuery, RouteRepository routeRepository, RoutesStationRepository routeStationRepository,
                     ProgramRepository programRepository, FindProgramsOfRouteStationQuery findProgramsOfRouteStationQuery,
                     RouteStationListQuery routeStationListQuery, RouteListQuery routeListQuery, CreateSpecificRouteQuery createSpecificRouteQuery,
                     StationRepository stationRepository)
 {
     this.routeStationForBetweenQuery = routeStationForBetweenQuery;
     this.companyRouteListQuery       = companyRouteListQuery;
     this.companyRepository           = companyRepository;
     this.routeListAllQuery           = routeListAllQuery;
     this.emptyProgramsListQuery      = emptyProgramsListQuery;
     this.seatRepository                  = seatRepository;
     this.seatListQuery                   = seatListQuery;
     this.routeRepository                 = routeRepository;
     this.routeStationRepository          = routeStationRepository;
     this.programRepository               = programRepository;
     this.findProgramsOfRouteStationQuery = findProgramsOfRouteStationQuery;
     this.routeStationListQuery           = routeStationListQuery;
     this.routeListQuery                  = routeListQuery;
     this.createSpecificRouteQuery        = createSpecificRouteQuery;
     this.stationRepository               = stationRepository;
 }
Ejemplo n.º 28
0
 public void Dispose()
 {
     this._userRepository               = null;
     this._permissionRepository         = null;
     this._roleRepository               = null;
     this._rolePermissionRepository     = null;
     this._investigatorRepository       = null;
     this._institutionRepository        = null;
     this._interestAreaRepository       = null;
     this._programRepository            = null;
     this._investigationGroupRepository = null;
     this._commissionRepository         = null;
     this._draftLawRepository           = null;
     this._conceptRepository            = null;
     this._badLanguageRepository        = null;
     this._tagRepository = null;
     this._conceptStatusLogRepository       = null;
     this._debateSpeakerRepository          = null;
     this._educationalInstitutionRepository = null;
     this._knowledgeAreaRepository          = null;
     this._academicLevelRepository          = null;
     this._educationLevelRepository         = null;
     this._snieRepository                     = null;
     this._meritRangeRepository               = null;
     this._investigatorCommissionRepository   = null;
     this._investigatorInterestAreaRepository = null;
     this._configurationRepository            = null;
     this._notificationRepository             = null;
     this._conceptDebateSpeakerRepository     = null;
     this._consultationRepository             = null;
     this._consultationInterestAreaRepository = null;
     this._draftLawStatusRepository           = null;
     this._periodRepository                   = null;
     this._originRepository                   = null;
     this._userInstitutionRepository          = null;
     this._consultationTypeRepository         = null;
     this._reasonRejectRepository             = null;
     _context.Dispose();
 }
Ejemplo n.º 29
0
        public ActionResponse AddNewProgram(ProgramDTO newProgram)
        {
            ProgramRepository repository = RepositoriesFactory.CreateRepository <ProgramRepository, Program>();

            ActionResponse response = ValidateProgram(newProgram);

            if (response == null)
            {
                Program programToSave = ConvertDTOToEntity(newProgram, true);

                repository.Add(programToSave);

                return(new ActionResponse()
                {
                    CompletedSuccessfully = true
                });
            }
            else
            {
                return(response);
            }
        }
Ejemplo n.º 30
0
        static void Main(string[] args)
        {
            var factory              = new BankingSystemContextFactory();
            var cityService          = new Repository <City>(factory);
            var disabilityService    = new Repository <Disability>(factory);
            var genderService        = new Repository <Gender>(factory);
            var maritalStatusService = new Repository <MaritalStatus>(factory);
            var nationalityService   = new Repository <Nationality>(factory);
            var passportService      = new Repository <Passport>(factory);
            var userService          = new Repository <User>(factory);
            var accountService       = new AccountRepository(factory);
            var accountTypeService   = new AccountTypeRepository(factory);
            var programService       = new ProgramRepository(factory);
            var programTypeService   = new ProgramTypeRepository(factory);
            var currencyService      = new CurrencyRepository(factory);
            //var x = accountService.GetAllAsync().Result;
            var currency = currencyService.GetAsync(1).Result;
            var program  = new Domain.Entities.Program()
            {
                Currency       = currency,
                DateStart      = DateTime.Now,
                DateEnd        = DateTime.Now,
                Name           = "lol",
                Percent        = 13,
                ProgramTypeId  = 1,
                TermMonthCount = 12
            };
            var x = programService.CreateAsync(program).Result;

            Console.WriteLine(x.Id);
            //foreach (var entity in x)
            //{
            //    Console.WriteLine(entity.Name);
            //    //foreach (var entityContract in entity.Programs)
            //    //{
            //    //    Console.WriteLine(entityContract.Name);
            //    //}
            //}
        }
Ejemplo n.º 31
0
        public static IList<Program> GeneralSqlQuery(string command)
        {
            using (IProgramRepository programRepository = new ProgramRepository(true))
            {
                IEnumerable<Mediaportal.TV.Server.TVDatabase.Entities.Program> allqueryprograms = programRepository.ObjectContext.ExecuteStoreQuery<Mediaportal.TV.Server.TVDatabase.Entities.Program>(command);
                programRepository.UnitOfWork.SaveChanges();
                IList<Program> myprograms = new List<Program>();
                foreach (Mediaportal.TV.Server.TVDatabase.Entities.Program rawprogram in allqueryprograms)
                {
                    Program myprogram = new Program(rawprogram.IdProgram);
                    myprogram.IdChannel = rawprogram.IdChannel;
                    myprogram.StartTime = rawprogram.StartTime;
                    myprogram.EndTime = rawprogram.EndTime;
                    myprogram.Title = rawprogram.Title;
                    myprogram.Description = rawprogram.Description;
                    if (rawprogram.ProgramCategory != null)
                        myprogram.Genre = rawprogram.ProgramCategory.Category;
                    else
                        myprogram.Genre = string.Empty;
                    try
                    {
                        myprogram.State = (Program.ProgramState)rawprogram.State; // rawprogram.State;
                    }
                    catch
                    {
                        myprogram.State = Program.ProgramState.None;
                    }
                    if (rawprogram.OriginalAirDate != null)
                    {
                        myprogram.OriginalAirDate = (DateTime)rawprogram.OriginalAirDate;
                    }
                    else
                    {
                        myprogram.OriginalAirDate = DateTime.ParseExact("2000-01-31_00:00", "yyyy-MM-dd_HH:mm", System.Globalization.CultureInfo.InvariantCulture);
                    }                    
                    myprogram.SeriesNum = rawprogram.SeriesNum;
                    myprogram.EpisodeNum = rawprogram.EpisodeNum;
                    myprogram.EpisodeName = rawprogram.EpisodeName;
                    myprogram.EpisodePart = rawprogram.EpisodePart;
                    myprogram.StarRating = rawprogram.StarRating;
                    myprogram.Classification = rawprogram.Classification;
                    myprogram.ParentalRating = rawprogram.ParentalRating;

                    /*Program myprogram = new Program(rawprogram.IdProgram, rawprogram.IdChannel, rawprogram.StartTime, rawprogram.EndTime, rawprogram.Title, 
                                                    rawprogram.Description, rawprogram.ProgramCategory.Category, 0, (DateTime)rawprogram.OriginalAirDate, 
                                                    rawprogram.SeriesNum, rawprogram.EpisodeNum, rawprogram.EpisodeName, rawprogram.EpisodePart, rawprogram.StarRating, 
                                                    rawprogram.Classification, rawprogram.ParentalRating);*/
                    myprograms.Add(myprogram);
                }
                return myprograms;
            }
        }