Exemplo n.º 1
0
        private static void UpdateEntity(Brochure brochure, BrochureEntity brochureEntity, bool updateFileContents)
        {
            brochureEntity.FolderName = brochure.Title;
            brochureEntity.Notes      = brochure.Description;
            if (brochure.Date.HasValue)
            {
                var date = brochure.Date.Value;
                brochureEntity.Day   = (byte)date.Day;
                brochureEntity.Month = (byte)date.Month;
                brochureEntity.Year  = (byte)date.Year;
            }
            else
            {
                brochureEntity.Day   = null;
                brochureEntity.Year  = brochure.Year;
                brochureEntity.Month = brochure.Month;
            }

            brochureEntity.Pages = brochure.Pages;

            var validLanguages = brochure.Languages.Where(lang => lang != null).Where(lang => lang.IsValid).Select(lang => lang.Name);

            brochureEntity.Languages = string.Join(";", validLanguages);

            if (updateFileContents)
            {
                brochureEntity.ContentUrl  = brochure.Content.ContentUrl?.ToString();
                brochureEntity.ContentSize = brochure.Content.ContentSizeMb;
            }
        }
Exemplo n.º 2
0
        public async Task CreateBrochure(Brochure brochure, string user)
        {
            var brochureEntity = new BrochureEntity
            {
                Image = new ImageData(),
                User  = user,
            };

            UpdateEntity(brochure, brochureEntity, false);

            await this.context.Brochures.AddAsync(brochureEntity);

            await this.context.SaveChangesAsync();

            brochure.Id = this.expander.ExpandAbsolute <Brochure>(new { id = brochureEntity.Id });
        }
Exemplo n.º 3
0
        private void MapStorageLocation(Brochure target, BrochureEntity sourceEntity)
        {
            if (this.principal?.HasPermission(Permissions.AdminSources) == true)
            {
                var cabinetName = (from cabinet in this.context.FileCabinets
                                   where cabinet.Id == sourceEntity.FileCabinet
                                   select $"{cabinet.Description} ({sourceEntity.FileOffset})")
                                  .SingleOrDefault();

                target.Location = new StorageLocation
                {
                    Id = this.expander.ExpandAbsolute <StorageLocation>(new
                    {
                        brochureId = sourceEntity.Id
                    }),
                    FilingCabinetId = sourceEntity.FileCabinet,
                    Name            = cabinetName ?? "Not filed yet",
                    Position        = sourceEntity.FileOffset
                };
            }
        }