public IHttpActionResult Bar(FooDTO foo) { // notify all connected clients GolbalHost.ConnectionManager.GetHubContext <FooHub>().Clients.All.newFoo(foo); return(Ok(foo)); }
public FooDTO Insert(FooDTO foo) { Foo fooModule = Mapper.Map <Foo>(foo); var fooReturn = new Foo(_fooRepository.InsertBaseObj(fooModule)); return(Mapper.Map <FooDTO>(fooReturn)); }
public void insert_then_get() { using (ServiceContainer _container = new ServiceContainer()) { FooService fooService = _container.GetInstance <FooService>(); Foo foo = new Foo() { Name = "Tom Chen", Birthday_Title = DateTime.Now, Address = "Beijing" }; FooDTO fooDTO = Mapper.Map <FooDTO>(foo); var baseObj = fooService.Insert(fooDTO); var aa = fooService.GetById(baseObj.Id); Assert.AreEqual(baseObj.Id, aa.Id); Assert.AreEqual(baseObj.BirthDayTitle, aa.BirthDayTitle); Assert.AreEqual(baseObj.Name, aa.Name); Assert.AreEqual(baseObj.Address_title, aa.Address_title); List <int> ids = new List <int>() { 1, 2, 3, 4, 5, 6 }; var bb = fooService.GetByIds(ids); } }
public void Setup() { _fooDTO = new FooDTO() { id = Guid.NewGuid(), Description = "Test to DataEntity" }; }
public void Should_Return_DTO() { FooDTO dto = null; dto = Map.FromDataEntity <FooDTO, GivenMapper.Entities.FooEntity>(_fooEntity); Assert.IsNotNull(dto); Assert.IsTrue(dto.id == _fooEntity.id && dto.Description == _fooEntity.Description); }
private static void ParseAndDump(string comment, string json) { Console.WriteLine("--- " + comment + " ---"); JsonSerializerSettings settings = new JsonSerializerSettings(); settings.Converters.Add(new DtoConverter()); FooDTO foo = JsonConvert.DeserializeObject <FooDTO>(json, settings); Dump(foo, ""); Console.WriteLine(); }
public void TestCreateAndFindById() { const int VALUE = 7357; var fooDto = new FooDTO(VALUE); var newDto = Maestro.Create(fooDto); Assert.IsFalse(newDto.HasError); var foundDto = Maestro.GetById(newDto.Value.Id); Assert.IsFalse(foundDto.HasError); Assert.AreEqual(VALUE, foundDto.Value.Value); }
public async Task TestAsyncStuff() { const int VALUE = 7357; var fooDto = new FooDTO(VALUE); var newDto = await Maestro.CreateAsync(fooDto); Assert.IsFalse(newDto.HasError); var foundDto = Maestro.GetById(newDto.Value.Id); Assert.IsFalse(foundDto.HasError); Assert.AreEqual(VALUE, foundDto.Value.Value); }
public static void Main(params string[] args) { // Configure mapper by type scanning & convention matching var mapper = ByConventionMapBuilder.Build(); var myDTO = new FooDTO { X = 10, Embedded = new FooDTO.EmbeddedDTO { Y = 5, Z = 9 } }; var mappedFoo = mapper.Map <MyMappedFoo, FooDTO>(myDTO); Console.WriteLine("X = {0}, Y = {1}, Z = {2}", mappedFoo.X, mappedFoo.Y, mappedFoo.Z); Console.WriteLine("Done"); Console.ReadLine(); }
public void TestCreateOrUpdate() { var fooDto = new FooDTO(int.MaxValue); var initialCount = Maestro.GetAll().Value.Count(); var newBar = Maestro.CreateOrUpdate(fooDto); Assert.AreEqual(initialCount + 1, Maestro.GetAll().Value.Count()); Assert.AreEqual(int.MaxValue, newBar.Value.Value); newBar.Value.Value = int.MinValue; newBar = Maestro.CreateOrUpdate(newBar.Value); Assert.AreEqual(initialCount + 1, Maestro.GetAll().Value.Count()); Assert.AreEqual(int.MinValue, newBar.Value.Value); }
public static void Main(params string[] args) { // Configure mapper manually var mapper = new Mapper(); mapper.CreateMap <MyMappedFoo, FooDTO>(); var myDTO = new FooDTO { X = 10, Embedded = new FooDTO.EmbeddedDTO { Y = 5, Z = 9 } }; var mappedFoo = mapper.Map <MyMappedFoo, FooDTO>(myDTO); Console.WriteLine("X = {0}, Y = {1}, Z = {2}", mappedFoo.X, mappedFoo.Y, mappedFoo.Z); Console.WriteLine("Done"); Console.ReadLine(); }
public void Apply(FooDTO foo) { //I don't remember if this is the correct order but you get the gyst this._mapper.Map <IFooDTO, IFooDTO>(this, foo); }
// Artificial example! public static int GetNameLength(this FooDTO foo) { return(foo.Name.Length); }