/// <summary>
        /// Creates a deep clone of the current invoice (all fields and properties)
        /// </summary>
        /// <param name="invoice">Invoice to clone</param>
        public async Task <Invoice> Clone(Invoice invoice)
        {
            try
            {
                var clonedInvoice = await Task.FromResult(CloneUtility.DeepClone(invoice));

                return(clonedInvoice ?? null);
            }
            catch
            {
                throw;
            }
        }
示例#2
0
        /// <summary>
        /// —оздание копии шаблона печати
        /// </summary>
        /// <param name="id">
        /// The id.
        /// </param>
        /// <returns>
        /// The <see cref="Template"/>.
        /// </returns>
        public Template CreateCopyOfTemplate(Guid id)
        {
            var fromTemplate = GetById(id);
            var result       = CloneUtility.DeepClone(fromTemplate);

            result.Id      = Guid.Empty;
            result.Default = false;
            result.Name    = string.Format(" опи¤ - {0}", result.Name);
            if (result.Name.Length > 500)
            {
                result.Name = result.Name.Substring(0, 500);
            }

            var session = ObjectFactory.GetInstance <ISessionFactory>().GetCurrentSession();

            session.Evict(fromTemplate);
            SaveOrUpdate(result);
            session.Flush();
            return(result);
        }