public async Task <GenericActionResult <Job> > SaveJob(AddJobModel jobModel, string webRootPath, string userId) { try { var job = new Job { Compensation = jobModel.Compensation, DateCreated = DateTime.Now, Address = jobModel.Address, Description = jobModel.Description, TalentId = jobModel.TalentId, UserId = userId, Name = jobModel.Name, Disabled = false, DueDate = jobModel.DueDate, Gender = jobModel.Gender, CountryId = jobModel.CountryId, ProfileImageName = await UploadFile.SaveFileInWebRoot(jobModel.ProfileImage, webRootPath) }; context.Jobs.Add(job); context.SaveChanges(); return(new GenericActionResult <Job>(true, "Job saved successfully.", job)); } catch (Exception) { return(new GenericActionResult <Job>("Failed to save job, please try again or contact the administrator.")); } }
public IActionResult Post(AddJobModel jobModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = new JobManager(context, userManager).SaveJob(jobModel, hostingEnvironment.WebRootPath, User.FindFirst(ClaimTypes.NameIdentifier).Value).Result; return(Ok(new { success = result.Success, message = result.Message, data = result.Data })); }
public IActionResult AddRecurringJob([FromBody] AddJobModel jobModel) { try { RecurringJob.AddOrUpdate(jobModel.Name, () => HangfireService.HttpJob.HttpJobExcuter.PlatformExcute(jobModel.Url, jobModel.Data), jobModel.Corn, TimeZoneInfo.Local); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task <IActionResult> Post(AddJobModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (model.CommandId == Guid.Empty) { model.CommandId = NewId.NextGuid(); } var command = new AddJobCommand(model); await Send(command); return(Accepted(new PostResult <AddJobCommand>() { CommandId = model.JobId, Timestamp = command.Timestamp })); }
public AddJobCommand(AddJobModel model) { _model = model; Timestamp = DateTime.UtcNow; }