Пример #1
0
        public async Task <ActionResult <Label> > AddLabel([FromBody] Label label)
        {
            var res = await lr.AddLabel(label, HttpContext.Items["UserID"].ToString());

            if (res == null)
            {
                return(BadRequest("Label with same name already exists"));
            }
            return(res);
        }
Пример #2
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)));
        }
Пример #3
0
 /// <summary>
 /// Add New Label
 /// </summary>
 /// <param name="model">Label Model</param>
 /// <returns>true or false</returns>
 public bool AddLabel(LabelModel model)
 {
     try
     {
         var result = repository.AddLabel(model);
         return(result);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
 public async Task <IActionResult> AddLabel(Label label)
 {
     return(Ok(await _labelRepository.AddLabel(label)));
 }