Example #1
0
        public IHttpActionResult PostTags(TagModel model)
        {
            try
            {
                _logger.Debug(string.Format("ini process - Post,idUser:{0}", CurrentIdUser));

                if (!ModelState.IsValid)
                {
                    _logger.Debug(string.Format("ini Post - inValid,idUser:{0}", CurrentIdUser));
                    return(BadRequest(ModelState));
                }

                Tag tag = AutoMapper.Mapper.Map <Tag>(model);
                tag.LastActivityIdUser = CurrentIdUser;
                tag.CreationIdUser     = CurrentIdUser;

                _tagBL.Insert(tag);
                _logger.Debug(string.Format("finish Post - success,idUser:{0}", CurrentIdUser));

                return(Ok(new JsonResponse {
                    Success = true, Message = "Tag was Saved successfully", Data = tag
                }));
            }
            catch (Exception ex)
            {
                LogError(ex);
                return(InternalServerError(ex));
            }
        }
Example #2
0
        public async Task <IActionResult> Post([FromBody] Tag viewModel)
        {
            var created = await _tagBL.Insert(viewModel);

            return(CreatedAtAction(nameof(GetById), new { id = created.Id }, created));
        }