예제 #1
0
        /// <summary>
        /// Deletes the specified package.
        /// </summary>
        /// <param name="package">The package.</param>
        /// <param name="updateHistorical">if set to <c>true</c> [update historical].</param>
        /// <returns></returns>
        public Boolean Delete(ref BLModel.Package package, bool updateHistorical = true)
        {
            DLModel.Package existingPkg = new DLModel.Package();
            if (package.TitleIds.ToList().Any())
            {
                existingPkg = packageQuery.GetBy(package.TitleIds.ToList(), package.DestinationCode, package.Type);
            }

            if (package.ContentIds.ToList().Any())
            {
                existingPkg = packageQuery.GetBy(package.ContentIds.ToList(), package.DestinationCode, package.Type);
            }

            if (!string.IsNullOrEmpty(package.AiringId))
            {
                existingPkg = packageQuery.GetBy(package.AiringId, package.DestinationCode, package.Type);
            }
            var user = cntx.GetUser();

            if (existingPkg != null)
            {
                package = existingPkg.ToBusinessModel <DLModel.Package, BLModel.Package>();
                existingPkg.ModifiedBy       = user.UserName;
                existingPkg.ModifiedDateTime = DateTime.UtcNow;
                packagePersist.Delete(existingPkg, user.UserName, updateHistorical);
                return(true);
            }

            return(false);
        }
예제 #2
0
        /// <summary>
        /// Saves the package.
        /// </summary>
        /// <param name="package">The package business model.</param>
        /// <param name="updateHistorical">if set to <c>true</c> [update historical].</param>
        /// <returns></returns>
        public BLModel.Package SavePackage(BLModel.Package package, bool updateHistorical)
        {
            var user = cntx.GetUser();

            package.CreatedBy        = user.UserName;
            package.CreatedDateTime  = DateTime.UtcNow;
            package.ModifiedBy       = user.UserName;
            package.ModifiedDateTime = DateTime.UtcNow;

            return
                (packagePersist.Save(package.ToDataModel <BLModel.Package, DLModel.Package>(), user.UserName, updateHistorical)
                 .ToBusinessModel <DLModel.Package, BLModel.Package>());
        }