コード例 #1
0
ファイル: ConsumersService.cs プロジェクト: daumenas/Bakis
        public async Task Update(int id, UpdateConsumerDto updateConsumerData)
        {
            if (updateConsumerData == null)
            {
                throw new ArgumentNullException(nameof(updateConsumerData));
            }

            var consumerToUpdate = await _repository.GetById(id);

            if (consumerToUpdate == null)
            {
                throw new InvalidOperationException();
            }

            if (updateConsumerData.Email != consumerToUpdate.Email)
            {
                // email has changed so check if the new email is already taken
                if (_repository.FindByEmail(updateConsumerData.Email).Result != null)
                {
                    throw new Exception("Email " + updateConsumerData.Email + " is already taken");
                }
            }

            _mapper.Map(updateConsumerData, consumerToUpdate);

            await _repository.Update(consumerToUpdate);

            await _userService.Update(id, updateConsumerData);
        }
コード例 #2
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);
        }
コード例 #3
0
        public IResult Update(ConsumerDto consumerDto)
        {
            ConsumerEntity consumer = _consumerRepository.Get(consumerDto.Identification);

            consumer.SetPhoneNumer(consumerDto.PhoneNumber);
            consumer.SetCpf(consumerDto.CPF);
            consumer.SetTable(consumerDto.Table);

            consumer.Validate();

            if (consumer.Invalid)
            {
                return(new ValidateResult(consumer.Notifications, false, "Problemas ao atualizar os dados do cliente"));
            }

            _consumerRepository.Update(consumer);
            return(new ValidateResult(consumer, true, "Cliente atualizado com sucessso"));
        }
コード例 #4
0
ファイル: ConsumerService.cs プロジェクト: zzdxpq007/xms
 public bool Update(Consumer entity)
 {
     return(_consumerRepository.Update(entity));
 }
コード例 #5
0
 public bool Update(Consumer t)
 {
     return(consumerRepository.Update(t));
 }