public int Save(Output output)
        {
            int       id        = 0;
            XmlOutput xmlOutput = new XmlOutput();

            try
            {
                context.Outputs.Add(output);
                context.SaveChanges();

                id = output.Id;

                if (id > 0)
                {
                    foreach (OutputDetail detail in output.Details)
                    {
                        detail.OutputId = id;
                        context.OutputDetails.Add(detail);
                    }

                    context.SaveChanges();

                    bool result = xmlOutput.Create(id); //Create XML

                    //Update Amounts
                    //IWarehouseProductRepository _warehouseProductRepository = new WarehouseProductRepository();

                    //foreach (OutputDetail detail in output.Details)
                    //{
                    //  _warehouseProductRepository.UpdateAmountByCode(detail.Warehouse, detail.Quantity, detail.ProductCode);
                    //}
                }
            }
            catch (Exception ex)
            {
                id = 0;
                Debug.Write(@"Error " + ex.Message);
            }
            return(id);
        }