public void AddData_NullUserId_ThrowArgumentException() { var log = new ServiceLogs { Id = new Guid() }; Assert.Throws <ArgumentException>(() => _service.AddData(log, null, null)); }
public async Task <IActionResult> AddData([FromBody] ServiceLogDTO dto) { if (!ModelState.IsValid) { return(BadRequest()); } var userId = Utility.GetCurrentUserId(User); if (!await _servicesService.HaveUserAccess(userId, dto.ServiceId)) { return(Forbid()); } var log = _mapper.Map <ServiceLogs>(dto); log.UserId = userId; log = _service.AddData(log, dto.ServiceData, await _servicePropertiesService.GetValidPropertiesByServiceId(dto.ServiceId)); return(Ok(log.Id)); }