示例#1
0
        public Task Add([FromBody] Channel channel)
        {
            if (channel == null)
            {
                throw new ArgumentNullException(nameof(channel));
            }

            if (string.IsNullOrWhiteSpace(channel.Name))
            {
                throw new ArgumentNullException(nameof(channel.Name));
            }

            if (string.IsNullOrWhiteSpace(channel.Url))
            {
                throw new ArgumentNullException(nameof(channel.Url));
            }

            channel.LastNumber = 0;
            channel.LastPost   = DateTime.Now;

            try
            {
                return(_storage.AddChannelAsync(channel));
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc);
                return(Task.CompletedTask);
            }
        }