예제 #1
0
        public IHttpActionResult PostJob(Job job)
        {
            if (job == null)
            {
                return(BadRequest("Job object cannot be found in the request body."));
            }
            try
            {
                job.CreatedDate = DateTime.Now;
                jobsService.CreateJob(job);
                if (job.ProjectTaskId != null)
                {
                    jobsService.UpdateJobTaskActualStartDate((int)job.ProjectTaskId);
                }

                var jobs = jobsService
                           .GetJobs()
                           .Select(j => j.AutoMapObject <Job, Model.ViewModels.JobsListViewModel>());
                var partialView = Helpers.RenderPartial("~/Views/Shared/Partial/Jobs/JobsList.cshtml", jobs);
                return(Ok(partialView));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("Id,Title,Description,CreatedAt,ExpiresAt")] Job job)
        {
            if (ModelState.IsValid)
            {
                await _service.CreateJob(job);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(job));
        }