コード例 #1
0
        public async Task <IActionResult> Create(LeaveTypeDto leaveTypeDto)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(leaveTypeDto));
                }

                var leaveType = await _service.Create(leaveTypeDto.Name, leaveTypeDto.IsActive);

                if (leaveType.HasValue())
                {
                    return(RedirectToAction(nameof(Index)));
                }

                ModelState.AddModelError("", "Something went wrong...");
                return(View(leaveTypeDto));
            }
            catch (Exception e)
            {
                throw e;
            }
        }