public void Should_Throw_When_Creating_Monitor_With_Existing_Name()
        {
            MockExternalLinks();

            var userAndOrg = new UserAndOrganizationDTO()
            {
                OrganizationId = 2,
                UserId         = "1"
            };
            var monitor = new MonitorDTO()
            {
                Name = "Test1"
            };

            var ex = Assert.Throws <ValidationException>(() => _monitorService.CreateMonitor(monitor, userAndOrg));

            Assert.That(ex.ErrorCode, Is.EqualTo(ErrorCodes.DuplicatesIntolerable));
        }
        public IHttpActionResult CreateMonitor(CreateMonitorViewModel monitor)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var newMonitorDTO = _mapper.Map <CreateMonitorViewModel, MonitorDTO>(monitor);

            try
            {
                _monitorService.CreateMonitor(newMonitorDTO, GetUserAndOrganization());
            }
            catch (ValidationException e)
            {
                return(BadRequestWithError(e));
            }

            return(Ok());
        }