public IResult Delete(string guid)
        {
            if (!Util.IsGuid(guid))
            {
                return(new ValidateResult(null, false, "A identificação fornecida está inválida"));
            }

            ConsumerEntity consumer = _consumerRepository.Get(guid);

            _consumerRepository.Delete(consumer);

            return(new ValidateResult(null, true, "Clinte deletado com sucesso"));
        }
Beispiel #2
0
        public Consumer Authenticate(string username, string token)
        {
            var consumer = _consumerRepository.Get(username);

            if (consumer != null && consumer.ApiSecret.Equals(token))
            {
                return(consumer);
            }
            return(null);
        }
Beispiel #3
0
        public ShortMessageModel Post([FromBody] IncomingShortMessageModel incomingMessage)
        {
            if (incomingMessage == null)
            {
                return(new ShortMessageModel());
            }

            ShortMessageModel shortMessageModel = new ShortMessageModel()
            {
                Created = DateTime.Now,
                Text    = incomingMessage.Text
            };

            var consumer = valueRepository.Get(incomingMessage.ConsumerKey);

            //Consumer does not exist
            if (consumer == null)
            {
                consumer        = new ConsumerModel();
                consumer.Key    = incomingMessage.ConsumerKey;
                consumer.Secret = incomingMessage.ConsumerSecret;

                consumer.ShortMessages.Add(shortMessageModel);
                valueRepository.Update(consumer);
            }
            else
            {
                //Consumer already exists, check secret
                if (consumer.Secret == incomingMessage.ConsumerSecret)
                {
                    consumer.ShortMessages.Add(shortMessageModel);
                    valueRepository.Update(consumer);
                }
            }

            return(shortMessageModel);
        }