public IActionResult PostDeviceType([FromBody] DeviceTypeViewModel vmdl) { try { var dt = _bl.CreateDeviceType(); vmdl.ApplyChanges(dt, _bl); _bl.SaveChanges(); _log.LogInformation("DeviceType '{0}' created by '{1}'", vmdl.Name, User.Identity.Name); vmdl.Refresh(dt); return(Ok(vmdl)); } catch (SecurityException) { _log.LogWarning("Security: '{0}' tried to create DeviceType '{1}'", _bl.GetCurrentUid(), vmdl.Name); return(Unauthorized()); } catch (Exception ex) { _log.LogError("Exception: '{0}'", ex); return(StatusCode(500)); } }
public void bl_should_create_deviceType() { var obj = _bl.CreateDeviceType(); obj.Slug = "test"; obj.TypeId = 23; Assert.NotNull(obj); }