public async Task AddLabelTest() { LabelDto result = await _labelService.Add(new CreateLabelDto() { Description = "test", CreatedBy = 1 }); Assert.IsNotNull(result); Assert.AreEqual(1, result.LabelId); }
public async Task <IActionResult> Add(CreateLabelDto labelDto, ApiVersion version) { int userId = int.Parse(HttpContext.Items["UserId"].ToString()); if (labelDto == null || string.IsNullOrWhiteSpace(labelDto.Description)) { return(BadRequest(new ResponseModel <string> { IsSuccess = false, Result = "Not Updated.", Message = "Invalid request, Mandatory fields not provided in request." })); } labelDto.CreatedBy = userId; labelDto.UserId = userId; LabelDto createdLabel = await _labelService.Add(labelDto); return(CreatedAtAction(nameof(GetById), new { id = createdLabel.LabelId, version = $"{version}" }, createdLabel)); }