Пример #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory,
                              HrResorcesContext HrResorcesContext)
        {
            loggerFactory.AddConsole();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler();
            }
            HrResorcesContext.EnsureSeedDataForContext();
            app.UseStatusCodePages();



            AutoMapper.Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <Entities.Company, Models.CompaniesWithoutJobPositionDto>().ReverseMap();

                cfg.CreateMap <Entities.Company, Models.CompanyForUpdateDto>().ReverseMap();
                cfg.CreateMap <Entities.RegularUser, Models.RegularUserForUpdateDto>().ReverseMap();
                cfg.CreateMap <Entities.RegularUser, Models.RegularUserCreationDto>().ReverseMap();
                cfg.CreateMap <Entities.RegularUser, Models.RegularUserForList>().ReverseMap();
                cfg.CreateMap <Entities.JobPosition, Models.JobPositionForList>().ReverseMap();
                cfg.CreateMap <Entities.JobPosition, Models.JobPositionForCreationDto>().ReverseMap();
                cfg.CreateMap <Entities.JobPosition, Models.JobPositionForUpdateDto>().ReverseMap();
            });


            app.UseMvc();


            /*  app.Run( (context) =>
             * {
             *    throw new Exception("exeption");
             * });*/
        }
Пример #2
0
        public static void EnsureSeedDataForContext(this HrResorcesContext context)
        {
            if (context.Companies.Any())
            {
                return;
            }

            var companies = new List <Company>
            {
                new Company()

                {
                    Name        = "ABC",
                    Description = "Hardware",
                    City        = "Novi Sad",
                    Country     = "Serbia",
                    Phone       = "1111111",
                    EmailAdress = " ABC@co",
                    WebSite     = "www.ABC"
                }
            };


            {
                new Company()

                {
                    Name        = "DEG",
                    Description = "Software",
                    City        = "Atina",
                    Country     = "Greace",
                    Phone       = "1111111",
                    EmailAdress = " DEG@co",
                    WebSite     = "www.DEG"
                };

                if (context.Jobpositions.Any())
                {
                    return;
                }

                var jobPositions = new List <JobPosition>()

                {
                    new JobPosition()

                    {
                        JobName        = "Front end",
                        JobDescription = "Java",
                        JobCity        = "Novi Sad",
                        JobCountry     = "Serbia",
                        JobPartTime    = "Da",
                        JobKeyWords    = " Iskustvo 5 god",
                        CompanyName    = "ABC"
                    },
                };



                if (context.RegularUsers.Any())
                {
                    return;
                }

                var regularUsers = new List <RegularUser>()
                {
                    new RegularUser()

                    {
                        UserName                   = "******",
                        UserSurname                = "Zivkovic",
                        UserDateOfBirth            = "19.07.1967",
                        UserSex                    = "Muško",
                        UserCity                   = "Novi Sad",
                        UserVilingToChangeLocation = "Da",
                        UserFullTimeJob            = "Da",
                        UserWorkExperience         = " Da",
                        UserKeyWords               = "Hemičar"
                    },
                };



                context.Companies.AddRange(companies);

                context.Jobpositions.AddRange(jobPositions);
                context.RegularUsers.AddRange(regularUsers);

                context.SaveChanges();
            }
        }
 public HrResorcesRepository(HrResorcesContext context)
 {
     _context = context;
 }
 public DummyController(HrResorcesContext hrx)
 {
     _hrx = hrx;
 }