public SuccessResponse <LabelDto> CreateLabel([FromBody] CreateLabelDto createLabelDto) { var label = _mapper.Map <Label>(createLabelDto); var response = _labelService.CreateLabel(label); return(new SuccessResponse <LabelDto>(_mapper.Map <LabelDto>(response))); }
public async Task <IActionResult> AddLabel(Guid token, Guid projectUid, string labelKey) { var result = new CommonResult(); if (token.IsEmptyGuid() || projectUid.IsEmptyGuid() || labelKey.IsEmpty()) { result.Messages.Add("some parameters are missing! (token, projectUid, labelKey)"); return(Json(result)); } var request = new TokenValidateRequest(projectUid, token); var response = await _integrationService.ValidateToken(request); if (response.Status.IsNotSuccess) { result.Messages = response.ErrorMessages; result.Messages.Add("unauthorized"); return(StatusCode(401, result)); } var labelCreateWithTokenRequest = new LabelCreateWithTokenRequest(token, projectUid, labelKey); var labelsResponse = await _labelService.CreateLabel(labelCreateWithTokenRequest); if (labelsResponse.Status.IsNotSuccess) { response.ErrorMessages = labelsResponse.ErrorMessages; return(Json(result)); } result.IsOk = true; return(Json(result)); }
public async Task <ActionResult <Label> > PostLabel([FromBody] LabelDTO labelDTO) { if (labelDTO.Name == null) { return(BadRequest(new { message = "Label Name mandatory" })); } var label = _mapper.Map <LabelDTO, Label>(labelDTO); await _labelService.CreateLabel(label); return(CreatedAtAction("GetLabel", new { id = label.Id }, label)); }
public async Task <IActionResult> Create(LabelCreateModel model) { if (model.IsNotValid()) { model.SetInputModelValues(); return(View(model)); } var request = new LabelCreateRequest(CurrentUser.Id, model.OrganizationUid, model.ProjectUid, model.Key, model.Description); var response = await _labelService.CreateLabel(request); if (response.Status.IsNotSuccess) { model.MapMessages(response); model.SetInputModelValues(); return(View(model)); } CurrentUser.IsActionSucceed = true; return(Redirect($"/Label/Detail/{response.Item.Uid}")); }
public async Task <Label> AddLabel(LabelDTO label) { var labelInput = _mapper.Map <LabelDTO, Label>(label); return(await _labelService.CreateLabel(labelInput)); }