public void Build_ShouldThrowAnExceptionIfTheJewelIdDoesntExists()
        {
            //Arrange
            var jewelRepository = new FakeJewelRepository(new FakeSettingManager()); ;

            var doesntExists = Tests.FAKE_JEWELRY_REPOSITORY_FIRST_ITEM_ID + 1000;
            var model = fixture.Build<EmailRingModel>().With(x => x.ID, doesntExists).CreateAnonymous();

            var builder = new EmailRingEmailTemplateViewModelBuilder(model, jewelRepository, mapper);
            //Act
            builder.Build();
        }
        public void Build_ShouldMapTheModelToTheTemplateViewModel()
        {
            //Arrange
            var jewelRepository = new FakeJewelRepository(new FakeSettingManager());
            var model = fixture.Build<EmailRingModel>().With(x=> x.ID,Tests.FAKE_JEWELRY_REPOSITORY_FIRST_ITEM_ID).CreateAnonymous();

            var builder = new EmailRingEmailTemplateViewModelBuilder(model,jewelRepository,mapper);
            //Act
            var template = builder.Build();
            //Assert
            template.YourName.Should().Be(model.YourName);
            template.YourEmail.Should().Be(model.YourEmail);
            template.ID.Should().Be(model.ID.ToString());
            template.Message.Should().Be(model.Message);
            template.FriendEmail.Should().Be(model.FriendEmail);
            template.FriendName.Should().Be(model.FriendName);
        }
        public void Build_ShouldMapTheJewelDetailsToTheViewModel()
        {
            //Arrange
            var jewelRepository = new FakeJewelRepository(new FakeSettingManager()); ;

            var model = fixture.Build<EmailRingModel>().With(x=> x.ID , Tests.FAKE_JEWELRY_REPOSITORY_FIRST_ITEM_ID).CreateAnonymous();

            var builder = new EmailRingEmailTemplateViewModelBuilder(model, jewelRepository, mapper);
            //Act
            var template = builder.Build();
            //Assert
            var jewel = FakeFactory.FirstJewelInRepository;

            template.Description.Should().Be(jewel.Title);
            template.ItemNumber.Should().Be(jewel.ItemNumber);
            template.Price.Should().Be(Tests.AsMoney(jewel.Price));
            template.Icon.Should().Be(jewel.Media.IconURLForWebDisplay);
            template.MediaSet.Should().Be(jewel.Media.MediaSet);
        }
        public ActionResult EmailRing(EmailRingModel model)
        {
            try
            {
                var builder = new EmailRingEmailTemplateViewModelBuilder(model, jewelRepository, mapper);
                var template = builder.Build();
                mailer.EmailRing(model.FriendEmail, template).Send();
                return Json(new OporationWithoutReturnValueJsonModel());
            }
            catch (Exception ex)
            {
                var viewModel = new OporationWithoutReturnValueJsonModel();
                viewModel.HasError = true;
                viewModel.ErrorMessage = ex.Message;

                return Json(viewModel);
            }
        }