public IHttpActionResult GetShiftById(int ShiftId) { JobShift result = SipDataEntity.JobShift.Where(x => x.id == ShiftId).FirstOrDefault(); //var result2 = result.ShiftPersons; var s = result.id; if (result != null) { return(Ok(result)); } return(NotFound()); }
public static Guid Create(string title, string short_desc, string salary_type, string status, string long_desc, Guid experience, Guid education, Guid location, Guid contact, int isDriving, List<Guid> categories, List<Guid> shifts) { JobBoardDataContext db = new JobBoardDataContext(); // Create the new job record Job new_job = new Job { id = Guid.NewGuid(), title = title, short_desc = short_desc, long_desc = long_desc.Replace("\n","<br />"), experience = experience, education = education, location = location, contact = contact, date_added = DateTime.Now, isDriving = isDriving, salary_type = salary_type, status = status, jobState = JobState.CREATED.ToString() }; // Save the job record db.Jobs.InsertOnSubmit(new_job); db.SubmitChanges(); // Create the job categories foreach (Guid cat_id in categories) { JobCategory new_jobcat = new JobCategory { job = new_job.id, cat = cat_id }; db.JobCategories.InsertOnSubmit(new_jobcat); } // Create the job categories foreach (Guid shift_id in shifts) { JobShift new_jobshift = new JobShift { id = Guid.NewGuid(), job = new_job.id, shift = shift_id }; db.JobShifts.InsertOnSubmit(new_jobshift); } db.SubmitChanges(); return new_job.id; }
public static string AddJobShift(Guid job_id, Guid shift_id) { JobBoardDataContext db = new JobBoardDataContext(); // Lets make sure we don't already have an association for this category int exists = db.JobShifts.Where(x => x.shift == shift_id && x.job == job_id).Count(); if (exists > 0) { return "You may not add this shift more than once."; } JobShift js = new JobShift { id = Guid.NewGuid(), job = job_id, shift = shift_id }; db.JobShifts.InsertOnSubmit(js); db.SubmitChanges(); JavaScriptSerializer jss = new JavaScriptSerializer(); return jss.Serialize(js); }