コード例 #1
0
        public async Task <IActionResult> Add(AddServiceDto addServiceDto)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            await _serviceService.AddServiceAsync(addServiceDto);

            return(RedirectToAction("list", "service"));
        }
コード例 #2
0
        public async Task <IActionResult> PostAsync(ServiceCreateModel value)
        {
            try
            {
                var result = await serviceService.AddServiceAsync(value);

                return(Ok(result));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        public async Task <IActionResult> AddService(ServiceViewModel newService)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Index"));
            }


            var successful = await _serviceService
                             .AddServiceAsync(newService);

            if (!successful)
            {
                return(BadRequest("Could not add service."));
            }

            return(RedirectToAction("Index"));
        }