コード例 #1
0
        public IHttpActionResult GetJobType(int id)
        {
            JobType jobType = db.JobTypes.Find(id);

            if (jobType == null)
            {
                return(NotFound());
            }

            return(Ok(ViewModelMapper.ToViewModelJobTypes(jobType)));
        }
コード例 #2
0
        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)));
        }
コード例 #3
0
        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)));
        }
コード例 #4
0
 // GET: api/JobTypes
 public List <JobTypeViewModel> GetJobTypes()
 {
     return(db.JobTypes.ToList().Select(x => ViewModelMapper.ToViewModelJobTypes(x)).ToList());
 }