예제 #1
0
        public ActionResult <BlockedIPReadDto> CreateBlockedIP(BlockedIPCreateDto blockedIPCreateDto)
        {
            var blockedIPModel = _mapper.Map <BlockedIP>(blockedIPCreateDto);

            _onlineDOD.CreateBlockedIP(blockedIPModel);
            _onlineDOD.SaveChanges();

            var blockedIPReadDto = _mapper.Map <BlockedIPReadDto>(blockedIPModel);

            Serilog.Log.Information($"[{this.Request.Host.Host}] POST /api/blocked-ips -> ID - {blockedIPReadDto.Id}");

            return(CreatedAtRoute(nameof(GetBlockedIPById), new { Id = blockedIPReadDto.Id }, blockedIPReadDto));
        }
예제 #2
0
        public ActionResult <MessageReadDto> CreateMessage(MessageCreateDto messageCreateDto)
        {
            messageCreateDto.Text = _htmlSanitizer.Sanitize(_profanityFilter.CensorString(messageCreateDto.Text));

            if (messageCreateDto.Text == "")
            {
                messageCreateDto.Text    = "<prázdna po vyfiltrovaní>";
                messageCreateDto.Deleted = true;
            }

            var messageModel = _mapper.Map <Message>(messageCreateDto);

            _onlineDOD.CreateMessage(messageModel);
            _onlineDOD.SaveChanges();

            var messageReadDto = _mapper.Map <MessageReadDto>(messageModel);

            //Serilog.Log.Information($"[{this.Request.Host.Host}] POST /api/messages -> ID - {messageReadDto.Id}");

            return(CreatedAtRoute(nameof(GetMessageById), new { Id = messageReadDto.Id }, messageReadDto));
        }