Ejemplo n.º 1
0
        public MessagesSendParams Save(Message msg, string nickname)
        {
            var user = new AnekProvider.DataModels.Entities.User()
            {
                UserProfile = msg.FromId.ToString(), UserName = nickname
            };

            string payload = msg.ReplyMessage != null ?
                             msg.ReplyMessage.Payload :
                             msg.ForwardedMessages.First().ForwardedMessages.First().Payload;

            var anek = (BaseAnek)JsonConvert.DeserializeObject(payload, _settings);

            anek.ID   = Guid.Empty;
            anek.User = Guid.Empty;
            _controller.Save(user, anek);

            return(new MessagesSendParams
            {
                RandomId = new DateTime().Millisecond,
                PeerId = msg.PeerId.Value,
                Message = "Анек успешно сохранён!",
            });
        }
Ejemplo n.º 2
0
        public MessagesSendParams CreateUserAnek(Message msg, string nickname)
        {
            if (msg.ReplyMessage.Text.Length > 990)
            {
                return new MessagesSendParams
                       {
                           RandomId = new DateTime().Millisecond,
                           PeerId   = msg.PeerId.Value,
                           Message  = "Слишком длинный анек("
                       }
            }
            ;

            var    args  = msg.ReplyMessage.Text.Split("~~~");
            string title = args[0].Trim();
            string text  = args[1].Trim();

            CustomAnek anek = new CustomAnek()
            {
                Text = text, Title = title
            };

            var user = new AnekProvider.DataModels.Entities.User()
            {
                UserProfile = msg.FromId.ToString(), UserName = nickname
            };

            _controller.Save(user, anek);

            return(new MessagesSendParams
            {
                RandomId = new DateTime().Millisecond,
                PeerId = msg.PeerId.Value,
                Message = "Анек успешно добавлен!",
            });
        }