public async Task <ActionResult <JobTypeDto> > Create(JobTypeRequest model)
        {
            var jobType = await _repository.Create(model);

            return(jobType != null
                ? Created(nameof(Create), jobType)
                : StatusCode(StatusCodes.Status500InternalServerError, null));
        }
Beispiel #2
0
        public async Task <JobTypeDto> Create(JobTypeRequest model)
        {
            var jobType = new Data.Models.JobType {
                Name = model.Name
            };

            _db.JobTypes.Add(jobType);
            await _db.SaveChangesAsync();

            return(await GetById(jobType.Id));
        }
Beispiel #3
0
        public async Task <JobTypeDto> Update(int id, JobTypeRequest model)
        {
            var jobType = await _db.JobTypes.FindAsync(id);

            jobType.Name = model.Name;

            _db.JobTypes.Update(jobType);

            await _db.SaveChangesAsync();

            return(await GetById(jobType.Id));
        }
        public async Task <ActionResult <JobTypeDto> > Update(int id, JobTypeRequest model)
        {
            var jobType = await _repository.GetById(id);

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

            var result = await _repository.Update(id, model);

            return(result != null
                ? Accepted(nameof(Update), result)
                : StatusCode(StatusCodes.Status500InternalServerError, null));
        }