//TODO: Mapper library like AutoMapper #region Mapper private static Item Map(PersistenceItem item) { if (item == null) { return(null); } return(new Item { Id = item.Id, Name = item.Name, Cost = item.Cost }); }
public Item CreateItem(Item item) { if (item == null) { return(null); } var insertItem = new PersistenceItem { Name = item.Name, Cost = item.Cost }; var result = _dataContext.Items.Add(insertItem); _dataContext.SaveChanges(); return(Map(result)); }