Пример #1
0
        public async Task <LabelResponseDto> AddLabelAsync(int userId, LabelRequestDto label)
        {
            Label labelModel = _mapper.Map <Label>(label);
            Note  isOwner    = await _notesRepository.GetOwnerOfLabel(label.NoteId, userId);

            if (isOwner == null)
            {
                throw new FundooException(ExceptionMessages.NO_SUCH_NOTE);
            }
            return(_mapper.Map <LabelResponseDto>(await _repository.AddLabel(labelModel, userId)));
        }
Пример #2
0
        public async Task <IActionResult> AddLabelAsync([FromBody] LabelRequestDto label)
        {
            int userId       = Convert.ToInt32(HttpContext.Items["userId"]);
            var createdLabel = await _service.AddLabelAsync(userId, label);

            return(Ok(new
            {
                Data = createdLabel,
                StatusCode = HttpStatusCode.OK,
                Message = ResponseMessages.SUCCESS
            }));
        }