예제 #1
0
        public async Task <IActionResult> Create(CreateJobTypeViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var result = await _jobTypeService.Add(Mapper.Map <JobType>(model));

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

            return(View("NotFound"));
        }
예제 #2
0
        public async Task <IActionResult> Create(CreateJobTypeViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var jobType = new JobType {
                Name = model.Name
            };

            _context.Add(jobType);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }