public static Tabacco ToEntity(this TabaccoDTO tabacco) { return(new Tabacco { Id = tabacco.Id, InternalId = tabacco.InternalId, Name = tabacco.Name, Type = tabacco.Type, Picture = tabacco.Picture, Power = tabacco.Power, CreatedAt = tabacco.CreatedAt != null ? (new DateTime(1970, 1, 1)).AddMilliseconds(double.Parse(tabacco.CreatedAt)) : new DateTime(), CreatedBy = tabacco.CreatedBy, LastModifiedAt = tabacco.LastModifiedAt != null ? (new DateTime(1970, 1, 1)).AddMilliseconds(double.Parse(tabacco.LastModifiedAt)) : new DateTime(), LastModifiedBy = tabacco.LastModifiedBy }); }
public async Task <ActionResult> Post([FromBody] TabaccoDTO tabacco) { var result = Mapper.ToDto(await this.tabaccosService.Add(Mapper.ToEntity(tabacco))); return(Created($"{Request.Path}/{result.Id}", result)); }