コード例 #1
0
 /// <summary>
 /// A method that convert Modals Prdocut => Entities.Product
 /// </summary>
 /// <param name="product"> a Modals.Product to convert</param>
 /// <returns> return a converted Modals.Product object</returns>
 public static DataAccess.Entities.Product Map(Library.Modals.Product product)
 {
     return(new DataAccess.Entities.Product
     {
         ProductId = product.ProductID,
         Name = product.Name,
         Type = product.Type,
         Price = (decimal)product.Price,
         RestrictedAmount = product.RestrictedAmount,
     });
 }
コード例 #2
0
        /// <summary>
        /// A method that will map between Inventory object and Dict(Library.Product,int)
        /// </summary>
        /// <param name="inventory"></param>
        /// <returns></returns>
        public static Dictionary <Library.Modals.Product, int> Map(ICollection <Project1.DataAccess.Entities.Inventory> inventory)
        {
            Dictionary <Library.Modals.Product, int> result = new Dictionary <Library.Modals.Product, int>();

            foreach (var item in inventory)
            {
                Library.Modals.Product pro = Mapper.Map(item.Product);
                result.Add(pro, item.Unit);
            }
            return(result);
        }