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(); }
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(); }
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); }
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; }
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"); }); }
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"); })); }