Esempio n. 1
0
        public HttpResponseMessage Create(ChannelModel model)
        {
            Regex reg = new Regex(@"^[^ %@#!*~&',;=?$\x22]+$");
            var   m   = reg.IsMatch(model.Name);

            if (!m)
            {
                return(PageHelper.toJson(PageHelper.ReturnValue(false, "存在非法字符!")));
            }
            else
            {
                var channelCon = new ChannelSearchCondition
                {
                    Name = model.Name
                };
                var totalCount = _channelService.GetChannelCount(channelCon);
                if (totalCount > 0)
                {
                    return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据已存在!")));
                }
                else
                {
                    var newParent = model.ParentId == 0 ? null : _channelService.GetChannelById(model.ParentId);
                    var channel   = new ChannelEntity
                    {
                        Name    = model.Name,
                        Status  = model.Status,
                        Parent  = newParent,
                        Adduser = _workContent.CurrentUser.Id,
                        Addtime = DateTime.Now,
                        UpdUser = _workContent.CurrentUser.Id,
                        UpdTime = DateTime.Now
                    };
                    if (_channelService.Create(channel) != null)
                    {
                        return(PageHelper.toJson(PageHelper.ReturnValue(true, "数据添加成功!")));
                    }
                    else
                    {
                        return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据添加失败!")));
                    }
                }
            }
        }
        public async Task <ActionResult> Create(ChannelCreateRequest values)
        {
            await channelService.Create(values);

            return(Ok());
        }
Esempio n. 3
0
        public IActionResult Create(ChannelCreateRequest command)
        {
            var channel = _channelService.Create(command.GroupId, command.Name);

            return(Created($"/api/channel/{@channel.Id}", null));
        }
Esempio n. 4
0
 /// <summary>
 /// Creates communication channels to listen for incoming messages
 /// </summary>
 private static void OpenChannels()
 {
     // creates the local channel instance for the CHANNEL service
     _channelService = App.Resolve<IChannelService>();
     _channelService.Create(Channels.CHANNEL);
 }