コード例 #1
0
 public ProductItem(DTO.ProductItem item)
 {
     InternalCode = item.InternalCode;
     Name         = item.Name;
     Description  = item.Description;
     Quantity     = item.Quantity;
     Price        = item.Price;
 }
コード例 #2
0
        public object SetDefaultFactory(int userId, Hashtable filters, out Library.DTO.Notification notification)
        {
            DTO.ProductItem data = new DTO.ProductItem();
            notification = new Notification()
            {
                Type = NotificationType.Success
            };

            int factoryID = (filters.ContainsKey("factoryID") && filters["factoryID"] != null && !string.IsNullOrEmpty(filters["factoryID"].ToString())) ? Convert.ToInt32(filters["factoryID"].ToString()) : 0;
            int productID = (filters.ContainsKey("productID") && filters["productID"] != null && !string.IsNullOrEmpty(filters["productID"].ToString())) ? Convert.ToInt32(filters["productID"].ToString()) : 0;

            try
            {
                using (var context = CreatContext())
                {
                    if (productID != 0)
                    {
                        var dbItem = context.Product.FirstOrDefault(o => o.ProductID == productID);

                        if (factoryID != 0)
                        {
                            dbItem.DefaultFactoryID = factoryID;
                        }
                        context.SaveChanges();

                        data = converter.DB2DTO_Product(dbItem);
                    }

                    //var dbItemReturn = context.StandardCostPriceOverviewRpt_Detail_View.FirstOrDefault(o => o.ProductID == productID);
                    //return AutoMapper.Mapper.Map<StandardCostPriceOverviewRpt_Detail_View, DTO.StandardCostPriceDetail>(dbItemReturn);
                }
            }
            catch (Exception ex)
            {
                notification = new Notification()
                {
                    Type = NotificationType.Error, Message = ex.Message
                };
            }

            return(data);
        }