コード例 #1
0
        public IActionResult PostAccessory([FromBody] AccessoryViewModel vmdl)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var obj = _bl.CreateAccessory();
                vmdl.ApplyChanges(obj, _bl);
                _bl.SaveChanges();
                vmdl.Refresh(obj);

                return(Ok(vmdl));
            }
            catch (Exception ex)
            {
                _log.LogError("Exception: {0}", ex);
                return(StatusCode(500));
            }
        }