コード例 #1
0
        public IActionResult Post(ServiceViewModel serviceVM)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Data Not Valid"));
            }

            try
            {
                if (serviceVM == null)
                {
                    return(BadRequest("Data cannot null"));
                }
                var data = _servicesService.AddService(serviceVM);
                return(Ok(data));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
コード例 #2
0
        public async Task <IActionResult> AddAdmin([FromBody] ServiceModel service)
        {
            var name = await _servicesService.AddService(ServiceMapper.Map(service));

            return(Ok(name));
        }