Ejemplo n.º 1
0
        public static PackageModel CreateModel(Package package)
        {
            var file_srv    = CompositionRoot.Resolve <IFileService>();
            var package_srv = CompositionRoot.Resolve <IPackageService>();

            PackageModel model = new PackageModel();

            model.Date           = package.Date;
            model.Id             = package.Id;
            model.Organization   = package.Organization != null ? package.Organization.Caption : string.Empty;
            model.OrganizationId = package.Organization != null ? package.Organization.Id : 0;
            model.ControllerId   = package.Controller.Id;
            model.Comment        = package.Comment;

            var files = new List <FileModelItem>();

            foreach (var file in package_srv.GetPackageFiles(package.Id))
            {
                files.Add(FileModelConverter.ToModelItem(file));
            }

            model.Files = files.ToArray();

            PrepareModel(model);

            return(model);
        }
Ejemplo n.º 2
0
        public static PackageModel CreateModel(IEnumerable <Int64> fileIds)
        {
            var file_srv = CompositionRoot.Resolve <IFileService>();


            PackageModel model = new PackageModel();

            model.Date = DateTime.Today;

            var files = new List <FileModelItem>();

            foreach (var id in fileIds)
            {
                var file = file_srv.GetFileById(id);
                if (file != null)
                {
                    //Если ОГВ еще не установлено, то устанавливаем ОГВ первого в списке дел
                    if (model.OrganizationId <= 0)
                    {
                        model.Organization   = file.Ogv.Caption;
                        model.OrganizationId = file.Ogv.Id;
                    }
                    files.Add(FileModelConverter.ToModelItem(file));
                }
            }

            model.Files = files.ToArray();

            PrepareModel(model);

            return(model);
        }