public async Task AddLabelTest() { LabelDto result = await _labelContract.AddLabel(new CreateLabelDto() { Description = "test", CreatedBy = 1 }); Assert.IsNotNull(result); Assert.AreEqual(1, result.LabelId); }
public async Task <IActionResult> CreateLabel(CreateLabelModel createLabelModel, ApiVersion version) { long userId = long.Parse(HttpContext.Items["UserId"].ToString()); if (createLabelModel == null || string.IsNullOrWhiteSpace(createLabelModel.Description)) { return(BadRequest(new ApiResponse <string> { IsSuccess = false, Result = "Not Updated.", Message = "Please enter correct values. Description should not be empty." })); } createLabelModel.CreatedBy = userId; CreateLabelDto createLabelDto = _mapper.Map <CreateLabelDto>(createLabelModel); LabelDto createdLabel = await _labelContract.AddLabel(createLabelDto); return(CreatedAtAction(nameof(GetLabelById), new { createdLabel.LabelId, version = $"{version}" }, createdLabel)); }