示例#1
0
        public async Task Test_BL_ListJobs()
        {
            //Arrange
            JobBusinessLogic businessLogic = new JobBusinessLogic(inMemory: true);

            //Act
            JobEntity newjob1 = new JobEntity()
            {
                JobId     = 1,
                Title     = ".Net Developer",
                CreatedAt = DateTime.Now,
                ExpiresAt = DateTime.Now.AddDays(30)
            };
            await businessLogic.CreateJob(newjob1);

            JobEntity newjob2 = new JobEntity()
            {
                JobId     = 2,
                Title     = "Backend Senior Developer",
                CreatedAt = DateTime.Now,
                ExpiresAt = DateTime.Now.AddDays(30)
            };
            await businessLogic.CreateJob(newjob2);

            var list = await businessLogic.ListJobs();

            //Assert
            Assert.True(list.Count == 2, $"{list.Count} Jobs listed");
        }
示例#2
0
        public async Task Test_BL_DeleteJob()
        {
            //Arrange
            JobBusinessLogic businessLogic = new JobBusinessLogic(inMemory: true);
            JobEntity        newjob        = new JobEntity()
            {
                JobId     = 1,
                Title     = "Backend Senior Developer",
                CreatedAt = DateTime.Now,
                ExpiresAt = DateTime.Now.AddDays(30)
            };

            //Act
            await businessLogic.CreateJob(newjob);

            var exists = businessLogic.JobExists(newjob.JobId);

            //Assert
            Assert.True(exists, "Job created");

            //Act
            await businessLogic.DeleteJob(newjob);

            exists = businessLogic.JobExists(newjob.JobId);

            //Assert
            Assert.False(exists, "Job deleted");
        }
        public async Task <IActionResult> Create([Bind("JobId,Title,Description,CreatedAt,ExpiresAt")] JobEntity jobEntity)
        {
            if (ModelState.IsValid)
            {
                await jobslogic.CreateJob(jobEntity);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(jobEntity));
        }
示例#4
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            await logic.CreateJob(JobEntity);

            return(RedirectToPage("./Index"));
        }
示例#5
0
        public async Task <ActionResult <JobEntity> > PostJob(JobEntity jobEntity)
        {
            await logic.CreateJob(jobEntity);

            return(CreatedAtAction("GetJob", new { id = jobEntity.JobId }, jobEntity));
        }