コード例 #1
0
        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)));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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}"));
        }
コード例 #5
0
ファイル: Mutation.cs プロジェクト: priyankacool10/ToDoAPI
        public async Task <Label> AddLabel(LabelDTO label)
        {
            var labelInput = _mapper.Map <LabelDTO, Label>(label);

            return(await _labelService.CreateLabel(labelInput));
        }