예제 #1
0
        public async Task <IActionResult> CreateCompany([FromBody] AddCompanyModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    User user = new User()
                    {
                        Active      = true,
                        Password    = model.Password,
                        User_TypeId = 1,
                        UserName    = model.UserName
                    };
                    _context.Add(user);
                    await _context.SaveChangesAsync();

                    Company company = new Company()
                    {
                        Active      = true,
                        CompanyName = model.CompanyName,
                        UserId      = user.UserId
                    };
                    _context.Add(company);
                    await _context.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Ok(model));
        }
예제 #2
0
        public async static void Initialize(IServiceProvider serviceProvider)
        {
            using var context = new App_Context(serviceProvider.GetRequiredService <DbContextOptions <App_Context> >());
            context.Database.EnsureCreated();
            if (await context.USER_TYPE.AnyAsync())
            {
                return;   // DB has been seeded
            }
            var userTypes = new User_Type[]
            {
                new User_Type {
                    Id = 1, Active = true, Name = "Company User"
                },
                new User_Type {
                    Id = 2, Active = true, Name = "Applicant"
                }
            };

            foreach (User_Type userType in userTypes)
            {
                context.Add(userType);
            }
            context.Database.OpenConnection();
            context.Database.ExecuteSqlRaw(@"SET IDENTITY_INSERT dbo.USER_TYPE ON;");
            await context.SaveChangesAsync();

            context.Database.ExecuteSqlRaw(@"SET IDENTITY_INSERT dbo.USER_TYPE OFF;");
            context.Database.CloseConnection();
        }
        public async Task <IActionResult> CreateAplication([FromBody] JobApplicantModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var  ApplicationNo = GenerateApplicationNumber();
                    User user          = new User()
                    {
                        Active      = true,
                        Password    = model.Password,
                        User_TypeId = 2,
                        UserName    = model.UserName
                    };
                    _context.Add(user);
                    await _context.SaveChangesAsync();

                    Job_Applicant job_Applicant = new Job_Applicant()
                    {
                        Age              = model.Age,
                        ApplicantEmail   = model.ApplicantEmail,
                        ApplicantName    = model.ApplicantName,
                        ApplicantSurname = model.ApplicantSurname,
                        ApplicationNo    = ApplicationNo,
                        Expertise        = model.Expertise,
                        IsEmployed       = model.IsEmployed,
                        Job_ListingId    = model.Job_ListingId,
                        UserId           = user.UserId
                    };

                    _context.Add(job_Applicant);
                    await _context.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Ok(model));
        }
        public async Task <IActionResult> Create([Bind("Person_Id,duration,EndDate,IsEnd,Id,Ref,Price,Payement_date")] CustomerPayement customerPayement)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customerPayement);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Person_Id"] = new SelectList(_context.Customers, "Person_Id", "Person_Id", customerPayement.Person_Id);
            return(View(customerPayement));
        }
예제 #5
0
        public async Task <IActionResult> CreateJob([FromBody] JobListModel model)
        {
            try
            {
                Job_Listing job_Listing = new Job_Listing()
                {
                    CompanyId      = model.CompanyId,
                    Salary         = model.Salary,
                    JobDescription = model.JobDescription,
                    IsAvailable    = model.IsAvailable,
                    JobPosition    = model.JobPosition
                };

                _context.Add(job_Listing);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Ok(model));
        }