public void FromExpectMapAllProperties()
        {
            var entity = new Delivery
            {
                Id           = "id",
                Recipient    = new Recipient(),
                AccessWindow = new AccessWindow(),
                Order        = new Order(),
                State        = DeliveryState.Completed
            };

            var expectedRecipientDto = new RecipientDto();

            _mockRecipientMapper.Setup(mapper => mapper.From(entity.Recipient)).Returns(expectedRecipientDto);

            var expectedAccessWindowDto = new AccessWindowDto();

            _mockAccessWindowMapper.Setup(mapper => mapper.From(entity.AccessWindow)).Returns(expectedAccessWindowDto);

            var expectedOrderDto = new OrderDto();

            _mockOrderMapper.Setup(mapper => mapper.From(entity.Order)).Returns(expectedOrderDto);

            var actual = _deliveryMapper.From(entity);

            Assert.NotNull(actual);
            Assert.Equal(entity.Id, actual.Id);
            Assert.Equal(expectedOrderDto, actual.Order);
            Assert.Equal(expectedRecipientDto, actual.Recipient);
            Assert.Equal(expectedAccessWindowDto, actual.AccessWindow);
            Assert.Equal(entity.State, actual.State);
        }
        public async Task <int> Add(RecipientDto recipient)
        {
            await _validator.ValidateForAdding(recipient);

            var recipientEntity = _mapper.Map <Recipient>(recipient);

            return(await _recipientRepository.Add(recipientEntity));
        }
 public ResetPasswordEmailNotification(
     ResetPasswordEmailModel model,
     RecipientDto recipients,
     string baseHtmlTemplate,
     string htmlTemplate) : base(recipients)
 {
     TemplateModel    = model;
     Subject          = "Password Reset Request";
     BaseHtmlTemplate = baseHtmlTemplate;
     HtmlTemplate     = htmlTemplate;
 }
示例#4
0
 public ChangePasswordEmailNotification(
     ChangePasswordEmailModel model,
     RecipientDto recipients,
     string baseHtmlTemplate,
     string htmlTemplate) : base(recipients)
 {
     TemplateModel    = model;
     Subject          = "Change Password";
     HtmlTemplate     = htmlTemplate;
     BaseHtmlTemplate = baseHtmlTemplate;
 }
 public PasswordHasExpiredEmailNotification(
     PasswordHasExpiredEmailModel model,
     RecipientDto recipient,
     string baseHtmlTemplate,
     string htmlTemplate) : base(recipient)
 {
     TemplateModel    = model;
     Subject          = "Password Expired";
     HtmlTemplate     = htmlTemplate;
     BaseHtmlTemplate = baseHtmlTemplate;
 }
示例#6
0
        public Recipient To(RecipientDto from)
        {
            if (from == null)
            {
                return(null);
            }

            return(new Recipient
            {
                Address = from.Address,
                Email = from.Email,
                Name = from.Name,
                PhoneNumber = from.PhoneNumber
            });
        }
示例#7
0
        public IHttpActionResult CreateRecipient(RecipientDto recipientDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var recipient = Mapper.Map <Recipient>(recipientDto);

            _context.Recipients.Add(recipient);
            _context.SaveChanges();

            recipientDto.Id = recipient.Id;

            return(Created(new Uri(Request.RequestUri + "/" + recipient.Id), recipientDto));
        }
示例#8
0
 private CreateDeliveryCommand NewDeliveryCommand(
     AccessWindowDto accessWindow,
     OrderDto order,
     RecipientDto recipient,
     int userId,
     int partnerId)
 {
     return(new CreateDeliveryCommand
     {
         AccessWindow = accessWindow,
         Order = order,
         Recipient = recipient,
         PartnerId = partnerId,
         UserId = userId
     });
 }
        public void ToExpectMapAllProperties()
        {
            var dto = new RecipientDto
            {
                Address     = "expectedAddress",
                Email       = "expectedEmail",
                Name        = "expectedName",
                PhoneNumber = "expectedPhoneNumber"
            };

            var actual = _recipientMapper.To(dto);

            Assert.NotNull(actual);
            Assert.Equal(dto.Address, actual.Address);
            Assert.Equal(dto.Email, actual.Email);
            Assert.Equal(dto.Name, actual.Name);
            Assert.Equal(dto.PhoneNumber, actual.PhoneNumber);
        }
示例#10
0
        public IHttpActionResult UpdateRecipient(int id, RecipientDto recipientDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var recipientInDb = _context.Recipients.SingleOrDefault(r => r.Id == id);

            if (recipientInDb == null)
            {
                return(NotFound());
            }

            Mapper.Map(recipientDto, recipientInDb);

            _context.SaveChanges();

            return(Ok());
        }