public ActionResult Create(JobCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateJobService(); var skillList = new SelectList(service.SkillList(), "SkillId", "SkillName", model.SkillId); ViewBag.SkillId = skillList; var locationList = new SelectList(service.LocationList(), "LocationId", "FullLocation", model.LocationId); ViewBag.LocationId = locationList; if (service.CreateJob(model)) { TempData["SaveResult"] = $"{model.CompanyName}'s Job Was Created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", $"{model.CompanyName}'s Job Could Not Be Created."); return(View(model)); }
public IHttpActionResult Create(JobExecution body) { var jobBody = new JobCreate { Description = body.Description, CallbackUrl = "http://localhost:31901/destination", HttpVerb = "POST", Payload = $"{{ \"description\": \"{body.Description}\" }}", ContentType = "application/json", Headers = "source=Jobbie.Sample.Client.WebApi.Host" }; var scheduleBody = new ScheduleCreate { Description = body.Description, StartUtc = DateTime.UtcNow.AddSeconds(10), Cron = body.Cron }; var schedule = _client .Root() .Post(Relationships.Job_Create, jobBody, Curies.Jobbie) .Post(Relationships.Schedule_Create, scheduleBody, Curies.Jobbie) .Item <Schedule>() .Data; return(Ok(schedule)); }
public ActionResult <JobCreate> CreateJob(JobCreate jobCreate) { var jobModel = _mapper.Map <Job>(jobCreate); _data.CreateJob(jobModel); _data.SaveChanges(); var jobRead = _mapper.Map <JobRead>(jobModel); return(CreatedAtRoute(nameof(GetJobById), new { JobId = jobRead.Id }, jobRead)); }
public ActionResult Create(JobCreate model) { if (ModelState.IsValid) { var service = CreateJobService(); service.CreateJob(model); return(RedirectToAction("Index")); } return(View(model)); }
public IHttpActionResult Create([FromBody] JobCreate body) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var jobId = Guid.NewGuid(); var timeout = Convert(body.TimeoutInMilliseconds); _creator.Create(jobId, body.Description, body.CallbackUrl, body.HttpVerb, body.Payload, body.ContentType, body.Headers, timeout); return(Get(jobId)); }
public bool CreateJob(JobCreate model) { var entity = new Job() { Owner = model.Owner, Title = model.Title }; using (var ctx = new ApplicationDbContext()) { ctx.Jobs.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateJob(JobCreate model) { var service = _context.Services.Find(model.ServiceId); TimeSpan span; if (service.DurationUnit == DurationUnit.Minutes) { span = new TimeSpan(0, service.Duration, 0); } else { span = new TimeSpan(service.Duration, 0, 0); } var jobEntity = new Job { ClientId = model.ClientId, ServiceId = model.ServiceId, StartDate = model.StartDate, StartTime = model.StartTime, End = model.StartTime + span, Note = model.Note }; _context.Jobs.Add(jobEntity); int savedChangeToJobs = _context.SaveChanges(); var petIds = model.PetIds; int savedChangesToPetAssignments = 0; // Creating PetToJob assigments - need this becuase one job could have multiple pets and there could be multiple jobs for the same pet foreach (var petId in petIds) { var assignmentEntity = new PetToJob { PetId = petId, JobId = jobEntity.JobId }; _context.PetsToJobs.Add(assignmentEntity); savedChangesToPetAssignments += _context.SaveChanges(); } // CreateJob is succesful if one (from job save) plus the amount of pets on the job is equal the amount of saved changes return(savedChangeToJobs + savedChangesToPetAssignments == 1 + model.PetIds.Count()); }
public bool CreateJob(JobCreate model) { var entity = new JobsAvailable() { OwnerId = _userId, TitleOfJob = model.TitleOfJob, Description = model.Description, Pay = model.Pay, EquipmentAvailable = model.EquipmentAvailable, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Jobs.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(JobCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateJobService(); if (service.CreateJob(model)) { TempData["SaveResult"] = "Your job has been added to the list!"; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Oh no, your job could not be created!"); return(View(model)); }
public bool CreateJob(JobCreate model) { var jobEntity = new Job() { OwnerId = _UserId, JobPosition = model.JobPosition, JobRequirement = model.JobRequirement, JobDescription = model.JobDescription, JobType = model.JobType, Salary = model.Salary, CompanyId = model.CompanyId }; using (var ctx = new ApplicationDbContext()) { ctx.Jobs.Add(jobEntity); return(ctx.SaveChanges() == 1); } }
public IHttpActionResult PostJob(JobCreate model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (model is null) { return(BadRequest("You cannot have an empty input")); } var service = CreateJobServices(); if (!service.CreateJob(model)) { return(InternalServerError()); } return(Ok()); }
public ActionResult Create(JobCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateJobService(); if (service.CreateJob(model)) { TempData["SaveResult"] = "Your Job has been saved."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Job Could not be created."); return(View(model)); }
public bool CreateJob(JobCreate model) { var entity = new Job() { OwnerId = _userId, CompanyName = model.CompanyName, JobDescription = model.JobDescription, LocationId = model.LocationId, SkillId = model.SkillId, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Jobs.Add(entity); return(ctx.SaveChanges() == 1); } }