public void When_UpdateModel_is_mapped_to_an_Entity_and_the_Info_is_stringEmpty_then_all_fields_are_mapped_correctly_and_Info_in_the_result_is_null()
        {
            var entity = BandCreator.CreateSingle();

            BandProcess
                .Expect(process =>
                        process.GetBand())
                .Return(entity)
                .Repeat.Once();
            BandProcess.Replay();

            var updateModel = new AboutUpdateModel
                                  {
                                      DateFounded = DateTime.Now.AddMonths(-4).Date,
                                      Info = string.Empty,
                                  };

            var result = Mapper.Map(updateModel);

            Assert.AreEqual(entity.Id, result.Id, "Id not correct");
            Assert.AreEqual(updateModel.DateFounded.ToUniversalTime(), result.Founded, "Date founded not correct");
            Assert.AreEqual(null, result.Description, "Description not correct");

            BandProcess.VerifyAllExpectations();
        }
Example #2
0
        public void When_UpdateModel_is_mapped_to_an_Entity_and_the_Info_is_null_then_all_fields_are_mapped_correctly_and_Info_in_the_result_is_null()
        {
            var entity = BandCreator.CreateSingle();

            BandProcess
            .Expect(process =>
                    process.GetBand())
            .Return(entity)
            .Repeat.Once();
            BandProcess.Replay();

            var updateModel = new AboutUpdateModel
            {
                DateFounded = DateTime.Now.AddMonths(-4).Date,
                Info        = null,
            };

            var result = Mapper.Map(updateModel);

            Assert.AreEqual(entity.Id, result.Id, "Id not correct");
            Assert.AreEqual(updateModel.DateFounded.ToUniversalTime(), result.Founded, "Date founded not correct");
            Assert.AreEqual(null, result.Description, "Description not correct");

            BandProcess.VerifyAllExpectations();
        }
Example #3
0
        public Band Map(AboutUpdateModel model)
        {
            var entity = Process.GetBand();

            entity.Description = string.IsNullOrEmpty(model.Info) ? null : model.Info;
            entity.Founded     = model.DateFounded.ToUniversalTime();

            return(entity);
        }
Example #4
0
        public Band Map(AboutUpdateModel model)
        {
            var entity = Process.GetBand();

            entity.Description = string.IsNullOrEmpty(model.Info) ? null : model.Info;
            entity.Founded = model.DateFounded.ToUniversalTime();

            return entity;
        }
Example #5
0
        public async Task<ActionResult> EditAbout(AboutUpdateModel model)
        {
            return await CatalogsConsumerHelper.ExecuteWithCatalogScopeAsync(
                container =>
                {
                    var mapper = CatalogsConsumerHelper.ResolveCatalogsConsumer<IBandMapper>(container);
                    var entity = mapper.Map(model);

                    var process = CatalogsConsumerHelper.ResolveCatalogsConsumer<IBandProcess>(container);
                    process.UpdateBand(entity);

                    return RedirectToAction("About");
                });
        }
Example #6
0
        public async Task <ActionResult> EditAbout(AboutUpdateModel model)
        {
            return(await CatalogsConsumerHelper.ExecuteWithCatalogScopeAsync(
                       container =>
            {
                var mapper = CatalogsConsumerHelper.ResolveCatalogsConsumer <IBandMapper>(container);
                var entity = mapper.Map(model);

                var process = CatalogsConsumerHelper.ResolveCatalogsConsumer <IBandProcess>(container);
                process.UpdateBand(entity);

                return RedirectToAction("About");
            }));
        }