Exemplo n.º 1
0
        public async Task <IActionResult> Delete(DeleteJobTypeViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var jobType = await _context.JobTypes
                          .SingleOrDefaultAsync(m => m.JobTypeId == model.JobTypeId);

            _context.JobTypes.Remove(jobType);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Delete(DeleteJobTypeViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var jobType = _mapper.Map <JobType>(model);
            var result  = await _jobTypeService.Delete(jobType);

            if (result)
            {
                return(RedirectToAction(nameof(Index)));
            }

            return(View("NotFound"));
        }