Пример #1
0
        public async Task <WebResult <DanmuTable> > EditDanmu(DanmuTable data)
        {
            var result = await DanmuDao.EditDanmuAsync(data.Id, data.Data.Time, data.Data.Mode, data.Data.Color,
                                                       data.Data.Text, data.IsDelete);

            return(new WebResult <DanmuTable>(result));
        }
Пример #2
0
        public async Task <WebResult> Post([FromBody] BaseDanmuDataIn data)
        {
            if (string.IsNullOrWhiteSpace(data.Id) || string.IsNullOrWhiteSpace(data.Text))
            {
                return(new WebResult(1));
            }
            data.Ip = IPAddress.TryParse(Request.Headers["X-Real-IP"], out var ip)
                ? ip
                : Request.HttpContext.Connection.RemoteIpAddress;
            data.Referer ??= Request.Headers["Referer"].FirstOrDefault();
            var video = VideoDao.Insert(data.Id, new Uri(data.Referer ?? string.Empty));
            var danmu = new DanmuTable
            {
                Vid   = data.Id,
                Data  = data,
                Ip    = data.Ip,
                Video = video
            };
            var result = await DanmuDao.InsertDanmuAsync(danmu);

            return(new WebResult(result ? 0 : 1));
        }
Пример #3
0
        /// <summary>
        ///     插入弹幕
        /// </summary>
        /// <param name="danmu">弹幕信息</param>
        /// <returns>是否成功</returns>
        public async Task <bool> InsertDanmuAsync(DanmuTable danmu)
        {
            await _con.Danmu.AddAsync(danmu);

            return(await _con.SaveChangesAsync() > 0);
        }
Пример #4
0
 /// <summary>
 ///     插入弹幕
 /// </summary>
 /// <param name="danmu">弹幕信息</param>
 /// <returns>是否成功</returns>
 public async Task <bool> InsertDanmuAsync(DanmuTable danmu)
 {
     return(await Task.Run(() => !_danmuTable.Insert(danmu).IsNull));
 }