public IHttpActionResult GetJobType(int id) { JobType jobType = db.JobTypes.Find(id); if (jobType == null) { return(NotFound()); } return(Ok(ViewModelMapper.ToViewModelJobTypes(jobType))); }
public IHttpActionResult PostJobType(JobTypeViewModel jobTypeViewModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } JobType jobType = ViewModelMapper.ToModelJobTypes(jobTypeViewModel); db.JobTypes.Add(jobType); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = jobType.JobTypeId }, ViewModelMapper.ToViewModelJobTypes(jobType))); }
public IHttpActionResult DeleteJobType(int id) { JobType jobType = db.JobTypes.Find(id); if (jobType == null) { return(NotFound()); } db.JobTypes.Remove(jobType); db.SaveChanges(); return(Ok(ViewModelMapper.ToViewModelJobTypes(jobType))); }
// GET: api/JobTypes public List <JobTypeViewModel> GetJobTypes() { return(db.JobTypes.ToList().Select(x => ViewModelMapper.ToViewModelJobTypes(x)).ToList()); }